#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
#define LT(x) ((x) == 'I' ? 2 : (x) == 'O')
#define CMB(x, y) (((x) == (y)) ? (x) : (3 - ((x) + (y))))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MN 257171
int n, q;
vector<int> C[10], P;
struct SL {
vector<int> B;
int Vl[4 * MN], Eq[4 * MN], Lz[4 * MN];
void bld(int u, int s, int d) {
Lz[u] = Vl[u] = Eq[u] = 0;
if(s == d) {
Vl[u] = B[s];
Eq[u] = (B[s] == P[s]);
return;
}
bld(u * 2, s, (s + d) / 2);
bld(u * 2 + 1, (s + d) / 2 + 1, d);
Vl[u] = ((Vl[u * 2] == Vl[u * 2 + 1]) ? Vl[u * 2] : -1);
Eq[u] = Eq[u * 2] && Eq[u * 2 + 1];
}
SL(vector<int> E) : B(std::move(E)){
bld(1, 0, n-1);
}
void prp(int u, int s, int d) {
if(!Lz[u]) return;
int v = Lz[u] - 3;
Eq[u] = (Vl[u] == v);
if(s != d)
Lz[u * 2] = Lz[u * 2 + 1] = Lz[u];
Lz[u] = 0;
}
void pset(int l, int r, int v, int u, int s, int d) {
prp(u, s, d);
if(r < s || d < l) return;
if(l <= s && d <= r) {
Lz[u] = v + 3;
prp(u, s, d);
return;
}
pset(l, r, v, u * 2, s, (s + d) / 2);
pset(l, r, v, u * 2 + 1, (s + d) / 2 + 1, d);
Vl[u] = ((Vl[u * 2] == Vl[u * 2 + 1] )? Vl[u * 2] : -1);
Eq[u] = Eq[u * 2] && Eq[u * 2 + 1];
}
};
vector<SL> SS;
void af() {
int ok = 0;
for(auto &it : SS) ok |= it.Eq[1];
cout << (ok ? "Yes\n" : "No\n");
}
void rd(vi &C) {
string w;
cin >> w;
for(auto it : w) C.push_back(LT(it));
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
cin >> n;
for(int i = 0; i < 3; ++i) rd(C[i]);
int nr = 2;
for(int i = 0; i < 3; ++i)
for(int j = i + 1; j < 3; ++j)
for(int k = !(++nr); k < n; ++k) C[nr].push_back(CMB(C[i][k], C[j][k]));
for(int i = 0; i < n; ++i) C[6].push_back(CMB(C[0][i], CMB(C[1][i], C[2][i])));
for(int i = 0; i < n; ++i) C[7].push_back(CMB(C[1][i], CMB(C[0][i], C[2][i])));
for(int i = 0; i < n; ++i) C[8].push_back(CMB(C[2][i], CMB(C[0][i], C[1][i])));
cin >> q;
rd(P);
for(int i = 0; i < 9; ++i)
SS.emplace_back(C[i]);
af();
for(int i = 1, l, r; i <= q; ++i) {
char c;
cin >> l >> r >> c;
--l, --r;
for(auto &it : SS)
it.pset(l, r, LT(c), 1, 0, n - 1);
af();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
236 ms |
145412 KB |
Output is correct |
2 |
Correct |
271 ms |
145432 KB |
Output is correct |
3 |
Correct |
256 ms |
145352 KB |
Output is correct |
4 |
Correct |
228 ms |
145320 KB |
Output is correct |
5 |
Correct |
229 ms |
145396 KB |
Output is correct |
6 |
Correct |
228 ms |
145328 KB |
Output is correct |
7 |
Correct |
238 ms |
145384 KB |
Output is correct |
8 |
Correct |
238 ms |
145424 KB |
Output is correct |
9 |
Correct |
253 ms |
145320 KB |
Output is correct |
10 |
Correct |
246 ms |
145396 KB |
Output is correct |
11 |
Correct |
243 ms |
145320 KB |
Output is correct |
12 |
Correct |
234 ms |
145332 KB |
Output is correct |
13 |
Correct |
243 ms |
145484 KB |
Output is correct |
14 |
Correct |
232 ms |
145388 KB |
Output is correct |
15 |
Correct |
249 ms |
145368 KB |
Output is correct |
16 |
Correct |
245 ms |
145344 KB |
Output is correct |
17 |
Correct |
243 ms |
145316 KB |
Output is correct |
18 |
Correct |
245 ms |
145468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
236 ms |
145412 KB |
Output is correct |
2 |
Correct |
271 ms |
145432 KB |
Output is correct |
3 |
Correct |
256 ms |
145352 KB |
Output is correct |
4 |
Correct |
228 ms |
145320 KB |
Output is correct |
5 |
Correct |
229 ms |
145396 KB |
Output is correct |
6 |
Correct |
228 ms |
145328 KB |
Output is correct |
7 |
Correct |
238 ms |
145384 KB |
Output is correct |
8 |
Correct |
238 ms |
145424 KB |
Output is correct |
9 |
Correct |
253 ms |
145320 KB |
Output is correct |
10 |
Correct |
246 ms |
145396 KB |
Output is correct |
11 |
Correct |
243 ms |
145320 KB |
Output is correct |
12 |
Correct |
234 ms |
145332 KB |
Output is correct |
13 |
Correct |
243 ms |
145484 KB |
Output is correct |
14 |
Correct |
232 ms |
145388 KB |
Output is correct |
15 |
Correct |
249 ms |
145368 KB |
Output is correct |
16 |
Correct |
245 ms |
145344 KB |
Output is correct |
17 |
Correct |
243 ms |
145316 KB |
Output is correct |
18 |
Correct |
245 ms |
145468 KB |
Output is correct |
19 |
Correct |
1458 ms |
190984 KB |
Output is correct |
20 |
Correct |
1131 ms |
191016 KB |
Output is correct |
21 |
Correct |
949 ms |
190124 KB |
Output is correct |
22 |
Correct |
927 ms |
188608 KB |
Output is correct |
23 |
Correct |
431 ms |
148100 KB |
Output is correct |
24 |
Correct |
452 ms |
148256 KB |
Output is correct |
25 |
Correct |
998 ms |
191068 KB |
Output is correct |
26 |
Correct |
1012 ms |
191068 KB |
Output is correct |
27 |
Correct |
1243 ms |
190944 KB |
Output is correct |
28 |
Correct |
1220 ms |
191064 KB |
Output is correct |
29 |
Correct |
1101 ms |
190604 KB |
Output is correct |
30 |
Correct |
509 ms |
148144 KB |
Output is correct |
31 |
Correct |
1132 ms |
190976 KB |
Output is correct |
32 |
Correct |
1121 ms |
189668 KB |
Output is correct |
33 |
Correct |
462 ms |
148024 KB |
Output is correct |
34 |
Correct |
1183 ms |
190968 KB |
Output is correct |
35 |
Correct |
904 ms |
187176 KB |
Output is correct |
36 |
Correct |
474 ms |
148112 KB |
Output is correct |
37 |
Correct |
433 ms |
148116 KB |
Output is correct |
38 |
Correct |
972 ms |
190984 KB |
Output is correct |
39 |
Correct |
463 ms |
191064 KB |
Output is correct |
40 |
Correct |
974 ms |
170900 KB |
Output is correct |
41 |
Correct |
1586 ms |
191060 KB |
Output is correct |
42 |
Correct |
172 ms |
190940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
236 ms |
145412 KB |
Output is correct |
2 |
Correct |
271 ms |
145432 KB |
Output is correct |
3 |
Correct |
256 ms |
145352 KB |
Output is correct |
4 |
Correct |
228 ms |
145320 KB |
Output is correct |
5 |
Correct |
229 ms |
145396 KB |
Output is correct |
6 |
Correct |
228 ms |
145328 KB |
Output is correct |
7 |
Correct |
238 ms |
145384 KB |
Output is correct |
8 |
Correct |
238 ms |
145424 KB |
Output is correct |
9 |
Correct |
253 ms |
145320 KB |
Output is correct |
10 |
Correct |
246 ms |
145396 KB |
Output is correct |
11 |
Correct |
243 ms |
145320 KB |
Output is correct |
12 |
Correct |
234 ms |
145332 KB |
Output is correct |
13 |
Correct |
243 ms |
145484 KB |
Output is correct |
14 |
Correct |
232 ms |
145388 KB |
Output is correct |
15 |
Correct |
249 ms |
145368 KB |
Output is correct |
16 |
Correct |
245 ms |
145344 KB |
Output is correct |
17 |
Correct |
243 ms |
145316 KB |
Output is correct |
18 |
Correct |
245 ms |
145468 KB |
Output is correct |
19 |
Correct |
285 ms |
145348 KB |
Output is correct |
20 |
Correct |
291 ms |
145380 KB |
Output is correct |
21 |
Correct |
270 ms |
145540 KB |
Output is correct |
22 |
Correct |
239 ms |
145324 KB |
Output is correct |
23 |
Correct |
255 ms |
145344 KB |
Output is correct |
24 |
Correct |
257 ms |
145336 KB |
Output is correct |
25 |
Correct |
261 ms |
145320 KB |
Output is correct |
26 |
Correct |
252 ms |
145416 KB |
Output is correct |
27 |
Correct |
259 ms |
145360 KB |
Output is correct |
28 |
Correct |
237 ms |
145352 KB |
Output is correct |
29 |
Correct |
262 ms |
145364 KB |
Output is correct |
30 |
Correct |
246 ms |
145320 KB |
Output is correct |
31 |
Correct |
269 ms |
145416 KB |
Output is correct |
32 |
Correct |
257 ms |
145452 KB |
Output is correct |
33 |
Correct |
268 ms |
145376 KB |
Output is correct |
34 |
Correct |
253 ms |
145500 KB |
Output is correct |
35 |
Correct |
253 ms |
145448 KB |
Output is correct |
36 |
Correct |
273 ms |
145544 KB |
Output is correct |
37 |
Correct |
258 ms |
145364 KB |
Output is correct |
38 |
Correct |
261 ms |
145436 KB |
Output is correct |
39 |
Correct |
256 ms |
145472 KB |
Output is correct |
40 |
Correct |
260 ms |
145416 KB |
Output is correct |
41 |
Correct |
254 ms |
145500 KB |
Output is correct |
42 |
Correct |
262 ms |
145384 KB |
Output is correct |
43 |
Correct |
265 ms |
145440 KB |
Output is correct |
44 |
Correct |
268 ms |
145416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
236 ms |
145412 KB |
Output is correct |
2 |
Correct |
271 ms |
145432 KB |
Output is correct |
3 |
Correct |
256 ms |
145352 KB |
Output is correct |
4 |
Correct |
228 ms |
145320 KB |
Output is correct |
5 |
Correct |
229 ms |
145396 KB |
Output is correct |
6 |
Correct |
228 ms |
145328 KB |
Output is correct |
7 |
Correct |
238 ms |
145384 KB |
Output is correct |
8 |
Correct |
238 ms |
145424 KB |
Output is correct |
9 |
Correct |
253 ms |
145320 KB |
Output is correct |
10 |
Correct |
246 ms |
145396 KB |
Output is correct |
11 |
Correct |
243 ms |
145320 KB |
Output is correct |
12 |
Correct |
234 ms |
145332 KB |
Output is correct |
13 |
Correct |
243 ms |
145484 KB |
Output is correct |
14 |
Correct |
232 ms |
145388 KB |
Output is correct |
15 |
Correct |
249 ms |
145368 KB |
Output is correct |
16 |
Correct |
245 ms |
145344 KB |
Output is correct |
17 |
Correct |
243 ms |
145316 KB |
Output is correct |
18 |
Correct |
245 ms |
145468 KB |
Output is correct |
19 |
Correct |
1458 ms |
190984 KB |
Output is correct |
20 |
Correct |
1131 ms |
191016 KB |
Output is correct |
21 |
Correct |
949 ms |
190124 KB |
Output is correct |
22 |
Correct |
927 ms |
188608 KB |
Output is correct |
23 |
Correct |
431 ms |
148100 KB |
Output is correct |
24 |
Correct |
452 ms |
148256 KB |
Output is correct |
25 |
Correct |
998 ms |
191068 KB |
Output is correct |
26 |
Correct |
1012 ms |
191068 KB |
Output is correct |
27 |
Correct |
1243 ms |
190944 KB |
Output is correct |
28 |
Correct |
1220 ms |
191064 KB |
Output is correct |
29 |
Correct |
1101 ms |
190604 KB |
Output is correct |
30 |
Correct |
509 ms |
148144 KB |
Output is correct |
31 |
Correct |
1132 ms |
190976 KB |
Output is correct |
32 |
Correct |
1121 ms |
189668 KB |
Output is correct |
33 |
Correct |
462 ms |
148024 KB |
Output is correct |
34 |
Correct |
1183 ms |
190968 KB |
Output is correct |
35 |
Correct |
904 ms |
187176 KB |
Output is correct |
36 |
Correct |
474 ms |
148112 KB |
Output is correct |
37 |
Correct |
433 ms |
148116 KB |
Output is correct |
38 |
Correct |
972 ms |
190984 KB |
Output is correct |
39 |
Correct |
463 ms |
191064 KB |
Output is correct |
40 |
Correct |
974 ms |
170900 KB |
Output is correct |
41 |
Correct |
1586 ms |
191060 KB |
Output is correct |
42 |
Correct |
172 ms |
190940 KB |
Output is correct |
43 |
Correct |
285 ms |
145348 KB |
Output is correct |
44 |
Correct |
291 ms |
145380 KB |
Output is correct |
45 |
Correct |
270 ms |
145540 KB |
Output is correct |
46 |
Correct |
239 ms |
145324 KB |
Output is correct |
47 |
Correct |
255 ms |
145344 KB |
Output is correct |
48 |
Correct |
257 ms |
145336 KB |
Output is correct |
49 |
Correct |
261 ms |
145320 KB |
Output is correct |
50 |
Correct |
252 ms |
145416 KB |
Output is correct |
51 |
Correct |
259 ms |
145360 KB |
Output is correct |
52 |
Correct |
237 ms |
145352 KB |
Output is correct |
53 |
Correct |
262 ms |
145364 KB |
Output is correct |
54 |
Correct |
246 ms |
145320 KB |
Output is correct |
55 |
Correct |
269 ms |
145416 KB |
Output is correct |
56 |
Correct |
257 ms |
145452 KB |
Output is correct |
57 |
Correct |
268 ms |
145376 KB |
Output is correct |
58 |
Correct |
253 ms |
145500 KB |
Output is correct |
59 |
Correct |
253 ms |
145448 KB |
Output is correct |
60 |
Correct |
273 ms |
145544 KB |
Output is correct |
61 |
Correct |
258 ms |
145364 KB |
Output is correct |
62 |
Correct |
261 ms |
145436 KB |
Output is correct |
63 |
Correct |
256 ms |
145472 KB |
Output is correct |
64 |
Correct |
260 ms |
145416 KB |
Output is correct |
65 |
Correct |
254 ms |
145500 KB |
Output is correct |
66 |
Correct |
262 ms |
145384 KB |
Output is correct |
67 |
Correct |
265 ms |
145440 KB |
Output is correct |
68 |
Correct |
268 ms |
145416 KB |
Output is correct |
69 |
Correct |
1494 ms |
189404 KB |
Output is correct |
70 |
Correct |
1184 ms |
192004 KB |
Output is correct |
71 |
Correct |
445 ms |
148148 KB |
Output is correct |
72 |
Correct |
440 ms |
148288 KB |
Output is correct |
73 |
Correct |
456 ms |
148400 KB |
Output is correct |
74 |
Correct |
936 ms |
189456 KB |
Output is correct |
75 |
Correct |
454 ms |
148152 KB |
Output is correct |
76 |
Correct |
1040 ms |
192020 KB |
Output is correct |
77 |
Correct |
1000 ms |
189424 KB |
Output is correct |
78 |
Correct |
475 ms |
148208 KB |
Output is correct |
79 |
Correct |
473 ms |
148268 KB |
Output is correct |
80 |
Correct |
912 ms |
187452 KB |
Output is correct |
81 |
Correct |
477 ms |
148180 KB |
Output is correct |
82 |
Correct |
1063 ms |
191952 KB |
Output is correct |
83 |
Correct |
969 ms |
190972 KB |
Output is correct |
84 |
Correct |
466 ms |
148340 KB |
Output is correct |
85 |
Correct |
444 ms |
148192 KB |
Output is correct |
86 |
Correct |
1148 ms |
188172 KB |
Output is correct |
87 |
Correct |
1197 ms |
192056 KB |
Output is correct |
88 |
Correct |
540 ms |
148400 KB |
Output is correct |
89 |
Correct |
1085 ms |
190168 KB |
Output is correct |
90 |
Correct |
1220 ms |
192072 KB |
Output is correct |
91 |
Correct |
526 ms |
148148 KB |
Output is correct |
92 |
Correct |
983 ms |
188088 KB |
Output is correct |
93 |
Correct |
435 ms |
148112 KB |
Output is correct |
94 |
Correct |
459 ms |
148140 KB |
Output is correct |
95 |
Correct |
468 ms |
148172 KB |
Output is correct |
96 |
Correct |
997 ms |
191976 KB |
Output is correct |
97 |
Correct |
476 ms |
192020 KB |
Output is correct |
98 |
Correct |
1160 ms |
171468 KB |
Output is correct |
99 |
Correct |
1633 ms |
192032 KB |
Output is correct |
100 |
Correct |
198 ms |
192148 KB |
Output is correct |