You have a garland consisting of B' — colors of lamps in the garland).
You have to recolor some lamps in this garland (recoloring a lamp means changing its initial color to another) in such a way that the obtained garland is diverse.
A garland is called diverse if any two adjacent (consecutive) lamps (i. e. such lamps that the distance between their positions is 1) have distinct colors.
In other words, if the obtained garland is ti≠ti+1 should be satisfied.
Among all ways to recolor the initial garland to make it diverse you have to choose one with the minimum number of recolored lamps. If there are multiple optimal solutions, print any of them.
The first line of the input contains one integer 1≤n≤2⋅105) — the number of lamps.
The second line of the input contains the string B' — colors of lamps in the garland.
In the first line of the output print one integer diverse garland from the given one.
In the second line of the output print one string any of them.
9 RBGRRBRGG
2 RBGRGBRGR
8 BBBGBRRR
2 BRBGBRGR
13 BBRRRRGGGGGRR
6 BGRBRBGBGBGRG
#include<iostream> #include<stdio.h> #include<string.h> #define maxn 100000000 char str[maxn]; int n ,ans=0; using namespace std; int main() { cin>>n>>str; for(int i=0;i<n-1;i++) { if(str[i]==str[i+1]) { if(str[i]!='R'&&str[i+2]!='R') str[i+1]='R'; else if(str[i]!='G'&&str[i+2]!='G') str[i+1]='G'; else if(str[i]!='B'&&str[i+2]!='B') str[i+1]='B'; ans++; } } cout<<ans<<endl; for(int i=0;i<n;i++) cout<<str[i]; cout<<endl; return 0; }