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,i,r=0;
- string s;
- cin>>n>>s;
- i=1;
- while(i<n-1)
- {
- if(s[i]==s[i-1])
- {
- r++;
- if(s[i-1]=='G')
- {
- s[i]='B';
- if(s[i]==s[i+1])s[i]='R';
- }
- if(s[i-1]=='B')
- {
- s[i]='R';
- if(s[i]==s[i+1])s[i]='G';
- }
- if(s[i-1]=='R')
- {
- s[i]='G';
- if(s[i]==s[i+1])s[i]='B';
- }
- }
- i++;
- }
- if(s[i]==s[i-1])
- {
- r++;
- if(s[i-1]=='G')
- {
- s[i]='B';
- }
- if(s[i-1]=='B')
- {
- s[i]='R';
- }
- if(s[i-1]=='R')
- {
- s[i]='B';
- }
- }
- cout<<r<<endl<<s<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement