#include <bits/stdc++.h>
using namespace std;
constexpr int MAXN = 2e5 + 7;
map<int, bool> mapa;
int GENE[MAXN][3];
int gen[MAXN][9];
int wzorzec[MAXN];
int n, q;
void generate(){
// -(A+B)
for(int i = 1; i <= n; i++)
gen[i][0] = (-(GENE[i][0] + GENE[i][1]) + 6)%3;
// -(A+C)
for(int i = 1; i <= n; i++)
gen[i][1] = (-(GENE[i][0] + GENE[i][2]) + 6)%3;
// -(B+C)
for(int i = 1; i <= n; i++)
gen[i][2] = (-(GENE[i][1] + GENE[i][2]) + 6)%3;
// (A+B-C)
for(int i = 1; i <= n; i++)
gen[i][3] = ((GENE[i][0] + GENE[i][1] - GENE[i][2]) + 6)%3;
// (A-B+C)
for(int i = 1; i <= n; i++)
gen[i][4] = ((GENE[i][0] - GENE[i][1] + GENE[i][2]) + 6)%3;
//(-A+B+C)
for(int i = 1; i <= n; i++)
gen[i][5] = ((-GENE[i][0] + GENE[i][1] + GENE[i][2]) + 6)%3;
//default
for(int i = 1; i <= n; i++){
gen[i][6] = GENE[i][0];
gen[i][7] = GENE[i][1];
gen[i][8] = GENE[i][2];
}
}
void update(int a, int b, char c){
int x;
if(c == 'J') x = 0;
else if(c == 'O') x = 1;
else x = 2;
for(int i = a; i <= b; i++)
wzorzec[i] = x;
}
bool check(){
for(int i = 0; i < 9; i++){
bool can = 1;
for(int j = 1; j <= n; j++)
if(wzorzec[j] != gen[j][i]) can = 0;
if(can) return true;
}
return false;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
string str;
for(int i = 0; i <= 2; i++){
cin >> str;
for(int j = 0; j < n; j++){
int a;
if(str[j] == 'J') a = 0;
else if(str[j] == 'O') a = 1;
else a = 2;
GENE[j+1][i] = a;
}
}
generate();
cin >> q;
cin >> str;
for(int i = 1; i <= n; i++){
int a;
if(str[i-1] == 'J') a = 0;
else if(str[i-1] == 'O') a = 1;
else a = 2;
wzorzec[i] = a;
}
if(check()) cout << "Yes \n";
else cout << "No \n";
while(q--){
int a, b;
char c;
cin >> a >> b >> c;
update(a, b, c);
if(check()) cout << "Yes \n";
else cout << "No \n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
6508 KB |
Output is correct |
2 |
Correct |
160 ms |
6736 KB |
Output is correct |
3 |
Correct |
171 ms |
6892 KB |
Output is correct |
4 |
Correct |
147 ms |
6696 KB |
Output is correct |
5 |
Correct |
150 ms |
6740 KB |
Output is correct |
6 |
Correct |
149 ms |
6704 KB |
Output is correct |
7 |
Correct |
137 ms |
6832 KB |
Output is correct |
8 |
Correct |
154 ms |
6740 KB |
Output is correct |
9 |
Correct |
156 ms |
6796 KB |
Output is correct |
10 |
Correct |
158 ms |
6740 KB |
Output is correct |
11 |
Correct |
160 ms |
6756 KB |
Output is correct |
12 |
Correct |
157 ms |
6776 KB |
Output is correct |
13 |
Correct |
158 ms |
6736 KB |
Output is correct |
14 |
Correct |
159 ms |
6724 KB |
Output is correct |
15 |
Correct |
158 ms |
6820 KB |
Output is correct |
16 |
Correct |
158 ms |
6784 KB |
Output is correct |
17 |
Correct |
156 ms |
6736 KB |
Output is correct |
18 |
Correct |
149 ms |
6740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
6508 KB |
Output is correct |
2 |
Correct |
160 ms |
6736 KB |
Output is correct |
3 |
Correct |
171 ms |
6892 KB |
Output is correct |
4 |
Correct |
147 ms |
6696 KB |
Output is correct |
5 |
Correct |
150 ms |
6740 KB |
Output is correct |
6 |
Correct |
149 ms |
6704 KB |
Output is correct |
7 |
Correct |
137 ms |
6832 KB |
Output is correct |
8 |
Correct |
154 ms |
6740 KB |
Output is correct |
9 |
Correct |
156 ms |
6796 KB |
Output is correct |
10 |
Correct |
158 ms |
6740 KB |
Output is correct |
11 |
Correct |
160 ms |
6756 KB |
Output is correct |
12 |
Correct |
157 ms |
6776 KB |
Output is correct |
13 |
Correct |
158 ms |
6736 KB |
Output is correct |
14 |
Correct |
159 ms |
6724 KB |
Output is correct |
15 |
Correct |
158 ms |
6820 KB |
Output is correct |
16 |
Correct |
158 ms |
6784 KB |
Output is correct |
17 |
Correct |
156 ms |
6736 KB |
Output is correct |
18 |
Correct |
149 ms |
6740 KB |
Output is correct |
19 |
Execution timed out |
7042 ms |
11956 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
6508 KB |
Output is correct |
2 |
Correct |
160 ms |
6736 KB |
Output is correct |
3 |
Correct |
171 ms |
6892 KB |
Output is correct |
4 |
Correct |
147 ms |
6696 KB |
Output is correct |
5 |
Correct |
150 ms |
6740 KB |
Output is correct |
6 |
Correct |
149 ms |
6704 KB |
Output is correct |
7 |
Correct |
137 ms |
6832 KB |
Output is correct |
8 |
Correct |
154 ms |
6740 KB |
Output is correct |
9 |
Correct |
156 ms |
6796 KB |
Output is correct |
10 |
Correct |
158 ms |
6740 KB |
Output is correct |
11 |
Correct |
160 ms |
6756 KB |
Output is correct |
12 |
Correct |
157 ms |
6776 KB |
Output is correct |
13 |
Correct |
158 ms |
6736 KB |
Output is correct |
14 |
Correct |
159 ms |
6724 KB |
Output is correct |
15 |
Correct |
158 ms |
6820 KB |
Output is correct |
16 |
Correct |
158 ms |
6784 KB |
Output is correct |
17 |
Correct |
156 ms |
6736 KB |
Output is correct |
18 |
Correct |
149 ms |
6740 KB |
Output is correct |
19 |
Correct |
153 ms |
6736 KB |
Output is correct |
20 |
Correct |
163 ms |
6592 KB |
Output is correct |
21 |
Correct |
156 ms |
6740 KB |
Output is correct |
22 |
Correct |
117 ms |
6628 KB |
Output is correct |
23 |
Correct |
158 ms |
6840 KB |
Output is correct |
24 |
Correct |
148 ms |
6640 KB |
Output is correct |
25 |
Correct |
164 ms |
6720 KB |
Output is correct |
26 |
Correct |
130 ms |
6688 KB |
Output is correct |
27 |
Correct |
156 ms |
6880 KB |
Output is correct |
28 |
Correct |
144 ms |
6552 KB |
Output is correct |
29 |
Correct |
156 ms |
6740 KB |
Output is correct |
30 |
Correct |
119 ms |
6624 KB |
Output is correct |
31 |
Correct |
157 ms |
6800 KB |
Output is correct |
32 |
Correct |
157 ms |
6836 KB |
Output is correct |
33 |
Correct |
156 ms |
6736 KB |
Output is correct |
34 |
Correct |
126 ms |
6480 KB |
Output is correct |
35 |
Correct |
166 ms |
7040 KB |
Output is correct |
36 |
Correct |
158 ms |
6884 KB |
Output is correct |
37 |
Correct |
159 ms |
6736 KB |
Output is correct |
38 |
Correct |
160 ms |
6900 KB |
Output is correct |
39 |
Correct |
160 ms |
6868 KB |
Output is correct |
40 |
Correct |
157 ms |
6808 KB |
Output is correct |
41 |
Correct |
157 ms |
6768 KB |
Output is correct |
42 |
Correct |
157 ms |
6740 KB |
Output is correct |
43 |
Correct |
137 ms |
6736 KB |
Output is correct |
44 |
Correct |
171 ms |
6852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
6508 KB |
Output is correct |
2 |
Correct |
160 ms |
6736 KB |
Output is correct |
3 |
Correct |
171 ms |
6892 KB |
Output is correct |
4 |
Correct |
147 ms |
6696 KB |
Output is correct |
5 |
Correct |
150 ms |
6740 KB |
Output is correct |
6 |
Correct |
149 ms |
6704 KB |
Output is correct |
7 |
Correct |
137 ms |
6832 KB |
Output is correct |
8 |
Correct |
154 ms |
6740 KB |
Output is correct |
9 |
Correct |
156 ms |
6796 KB |
Output is correct |
10 |
Correct |
158 ms |
6740 KB |
Output is correct |
11 |
Correct |
160 ms |
6756 KB |
Output is correct |
12 |
Correct |
157 ms |
6776 KB |
Output is correct |
13 |
Correct |
158 ms |
6736 KB |
Output is correct |
14 |
Correct |
159 ms |
6724 KB |
Output is correct |
15 |
Correct |
158 ms |
6820 KB |
Output is correct |
16 |
Correct |
158 ms |
6784 KB |
Output is correct |
17 |
Correct |
156 ms |
6736 KB |
Output is correct |
18 |
Correct |
149 ms |
6740 KB |
Output is correct |
19 |
Execution timed out |
7042 ms |
11956 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |