Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits\stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- cin >> t;
- while(t--)
- {
- int n, i;
- cin >> n;
- string s;
- cin >> s;
- int cnt = 0;
- for(i = 0; i < n; i++)
- {
- if(s[i] == '?') cnt++;
- }
- if(cnt == n)
- {
- for(i = 0; i < n / 2; i++) printf("BR");
- if(n % 2 != 0) printf("B");
- printf("\n");
- }
- else
- {
- for(i = 0; i < n; i++)
- {
- if(s[i] == '?')
- {
- if(i > 0)
- {
- if(s[i-1] == 'R') s[i] = 'B';
- else if(s[i-1] == 'B') s[i] = 'R';
- }
- if(i < n)
- {
- if(s[i+1] == 'R') s[i] = 'B';
- else if(s[i+1] == 'B') s[i] = 'R';
- }
- }
- }
- for(i = n; i >= 0; i--)
- {
- if(s[i] == '?')
- {
- if(i > 0)
- {
- if(s[i-1] == 'R') s[i] = 'B';
- else if(s[i-1] == 'B') s[i] = 'R';
- }
- if(i < n)
- {
- if(s[i+1] == 'R') s[i] = 'B';
- else if(s[i+1] == 'B') s[i] = 'R';
- }
- }
- }
- cout << s << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement