【Codeforces Round #535 (Div. 3) C. Nice Garland(暴力)】题目链接:http://codeforces.com/contest/1108/problem/C
题意是给了一个长度为n的字符串,且字符串只包含'R','B','G'三种字符,可以改变任何一个字符,使得任意两个相同的字符的距离是3的倍数,输出改动最少的操作且输出改动后的字符串。
任意两个相同的字符的距离是3的倍数,换种说法其实就是RGBRGB这样的三个一循环,所以我们就把RGB的所有排列方式列出来然后暴力枚举找到改动最小的操作就好了。
AC代码:
#include
#define ll long long
using namespace std;
int main()
{
int len;
cin>>len;
string str;
cin>>str;
string a[6] = {"RGB", "RBG", "GRB", "GBR", "BRG","BGR"};
int ans = 0x3f3f3f3f , xx = -1;
for(int i=0;
i<6;
i++){
int cnt = 0;
for(int j=0;
j
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- codeforces B. Young Explorers
- codeforces C. Mere Array
- codeforces D. Omkar and Bed Wars
- codeforces C. Omkar and Waterslide
- codeforces B. Omkar and Infinity Clock
- codeforces B. Ternary Sequence
- 题库-CF|【Codeforces Round 370 (Div 2) E】【线段树 等比数列 区间合并】Memory and Casinos 赌场区间[l,r] l进r先出的概率
- 题库-CF|【Codeforces Round 263 (Div 2)C】【贪心 哈弗曼思维】Appleman and Toastman 每个非1size子树延展为2子树的最大权
- Codeforces|Codeforces Round #605 (Div. 3) D. Remove One Element
- Codeforces|Codeforces Round #643 (Div. 2) B.Young Explorers