You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
627 B
C++

#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
char a[] = "BGR";
const int N = 2e5 + 50;
char str[N], ans[4];
int main() {
int n;
scanf("%d%s", &n, str);
int ansc = 0x3f3f3f3f;
do {
int cnt = 0;
for (int i = 0; i < n; i++)
if (str[i] != a[i % 3])
cnt++;
if (cnt < ansc)
strcpy(ans, a), ansc = cnt;
} while (next_permutation(a, a + 3));
printf("%d\n", ansc);
for (int i = 0; i < n; i++) putchar(ans[i % 3]);
return 0;
}