Advertisement
jakaria_hossain

codeforce - Nice Garland

Mar 6th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define fastread()(ios_base::sync_with_stdio(false),cin.tie(NULL));
  4. #define ll long long
  5. int main()
  6. {
  7. fastread()
  8. int n,mx=1e9;
  9. string s, sub="BGR",ans;
  10. cin>>n>>s;
  11. do{
  12. int x=0;
  13. string str;
  14. for(int i=0;i<n;i++)
  15. {
  16. x+=(s[i]!=sub[i%3]);
  17. str+=sub[i%3];
  18. }
  19. if(mx>x)
  20. {
  21. mx=x;
  22. ans=str;
  23. }
  24. }while(next_permutation(sub.begin(),sub.end()));
  25. cout<<mx<<endl<<ans<<endl;
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement