Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define fastread()(ios_base::sync_with_stdio(false),cin.tie(NULL));
- #define ll long long
- int main()
- {
- fastread()
- int n,mx=1e9;
- string s, sub="BGR",ans;
- cin>>n>>s;
- do{
- int x=0;
- string str;
- for(int i=0;i<n;i++)
- {
- x+=(s[i]!=sub[i%3]);
- str+=sub[i%3];
- }
- if(mx>x)
- {
- mx=x;
- ans=str;
- }
- }while(next_permutation(sub.begin(),sub.end()));
- cout<<mx<<endl<<ans<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement