-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1108D.cpp
More file actions
38 lines (36 loc) · 738 Bytes
/
Copy path1108D.cpp
File metadata and controls
38 lines (36 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
Author : Chinmay Jha
@chinmayajha on Codeforces, Codechef, USACO, AtCoder and CSES.fi
Date: 2021-06-22 23:42:10
*/
#include "bits/stdc++.h"
using namespace std;
using lli = long long int;
using vi = vector<int>;
void solve(){
int n;
string s;
cin >> n;
cin >> s;
int cnt = 0;
for(int i=0;i<n;++i){
int j = i;
while(j<n && s[i]==s[j])j++;
string temp = "RGB";
temp.erase(temp.find(s[i]),1);
if(j<n)temp.erase(temp.find(s[j]),1);
for(int k=i+1;k<j;k+=2){
cnt++;
s[k] = temp[0];
}
i = j-1;
}
cout << cnt << endl << s;
}
int main(){
int t = 1;
// cin >> t;
while(t--){
solve();
}
}