-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1559B.cpp
85 lines (71 loc) · 1.26 KB
/
1559B.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, char> pi;
char next(char c){
if (c == 'R') return 'B';
else return 'R';
}
void solve(int n){
queue<pi> cola;
char c;
for (int i = 0; i < n; ++i){
cin >> c;
if (c == '?') continue;
cola.push(make_pair(i, c));
}
int ind = 0;
char letra = 'B';
pi p;
while (!cola.empty()){
p = cola.front();
cola.pop();
if (p.second == 'R'){
if ((p.first - ind) % 2 == 0) letra = 'R';
else letra = 'B';
} else {
if ((p.first - ind) % 2 == 0) letra = 'B';
else letra = 'R';
}
while (ind < p.first){
cout << letra;
letra = next(letra);
++ind;
}
cout << p.second;
letra = next(letra);
++ind;
}
while (ind < n){
cout << letra;
letra = next(letra);
++ind;
}
cout << "\n";
}
int main(){
int t, n;
cin >> t;
for (int i = 0; i < t; i++){
cin >> n;
solve(n);
}
return 0;
}
/*
5
7
?R???BR
7
???R???
1
?
1
B
10
?R??RB??B?
BRRBRBR
BRBRBRB
B
B
BRRBRBBRBR
*/