#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 207171
int n, q;
vector<int> C[9], 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> B) : B(std::move(B)){
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])));
cin >> q;
rd(P);
for(int i = 0; i < 7; ++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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
184 ms |
58752 KB |
Output is correct |
2 |
Correct |
197 ms |
58780 KB |
Output is correct |
3 |
Correct |
185 ms |
58736 KB |
Output is correct |
4 |
Correct |
172 ms |
58812 KB |
Output is correct |
5 |
Correct |
162 ms |
58716 KB |
Output is correct |
6 |
Correct |
169 ms |
58716 KB |
Output is correct |
7 |
Correct |
179 ms |
58812 KB |
Output is correct |
8 |
Correct |
176 ms |
58848 KB |
Output is correct |
9 |
Correct |
180 ms |
58688 KB |
Output is correct |
10 |
Correct |
178 ms |
58796 KB |
Output is correct |
11 |
Correct |
177 ms |
58756 KB |
Output is correct |
12 |
Correct |
168 ms |
58732 KB |
Output is correct |
13 |
Correct |
191 ms |
58792 KB |
Output is correct |
14 |
Correct |
170 ms |
58820 KB |
Output is correct |
15 |
Correct |
178 ms |
58792 KB |
Output is correct |
16 |
Correct |
177 ms |
58732 KB |
Output is correct |
17 |
Correct |
182 ms |
58788 KB |
Output is correct |
18 |
Correct |
172 ms |
58820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
184 ms |
58752 KB |
Output is correct |
2 |
Correct |
197 ms |
58780 KB |
Output is correct |
3 |
Correct |
185 ms |
58736 KB |
Output is correct |
4 |
Correct |
172 ms |
58812 KB |
Output is correct |
5 |
Correct |
162 ms |
58716 KB |
Output is correct |
6 |
Correct |
169 ms |
58716 KB |
Output is correct |
7 |
Correct |
179 ms |
58812 KB |
Output is correct |
8 |
Correct |
176 ms |
58848 KB |
Output is correct |
9 |
Correct |
180 ms |
58688 KB |
Output is correct |
10 |
Correct |
178 ms |
58796 KB |
Output is correct |
11 |
Correct |
177 ms |
58756 KB |
Output is correct |
12 |
Correct |
168 ms |
58732 KB |
Output is correct |
13 |
Correct |
191 ms |
58792 KB |
Output is correct |
14 |
Correct |
170 ms |
58820 KB |
Output is correct |
15 |
Correct |
178 ms |
58792 KB |
Output is correct |
16 |
Correct |
177 ms |
58732 KB |
Output is correct |
17 |
Correct |
182 ms |
58788 KB |
Output is correct |
18 |
Correct |
172 ms |
58820 KB |
Output is correct |
19 |
Correct |
1100 ms |
87784 KB |
Output is correct |
20 |
Correct |
811 ms |
87800 KB |
Output is correct |
21 |
Correct |
717 ms |
87192 KB |
Output is correct |
22 |
Correct |
706 ms |
86140 KB |
Output is correct |
23 |
Correct |
323 ms |
60480 KB |
Output is correct |
24 |
Correct |
322 ms |
60496 KB |
Output is correct |
25 |
Correct |
772 ms |
87784 KB |
Output is correct |
26 |
Correct |
805 ms |
87792 KB |
Output is correct |
27 |
Correct |
922 ms |
87804 KB |
Output is correct |
28 |
Correct |
921 ms |
87788 KB |
Output is correct |
29 |
Correct |
839 ms |
87528 KB |
Output is correct |
30 |
Correct |
368 ms |
60484 KB |
Output is correct |
31 |
Correct |
851 ms |
87772 KB |
Output is correct |
32 |
Correct |
809 ms |
86964 KB |
Output is correct |
33 |
Correct |
326 ms |
60428 KB |
Output is correct |
34 |
Correct |
868 ms |
87828 KB |
Output is correct |
35 |
Correct |
628 ms |
85116 KB |
Output is correct |
36 |
Correct |
319 ms |
60484 KB |
Output is correct |
37 |
Correct |
316 ms |
60596 KB |
Output is correct |
38 |
Correct |
680 ms |
87788 KB |
Output is correct |
39 |
Correct |
363 ms |
87896 KB |
Output is correct |
40 |
Correct |
662 ms |
75036 KB |
Output is correct |
41 |
Correct |
1152 ms |
87656 KB |
Output is correct |
42 |
Correct |
110 ms |
87800 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
184 ms |
58752 KB |
Output is correct |
2 |
Correct |
197 ms |
58780 KB |
Output is correct |
3 |
Correct |
185 ms |
58736 KB |
Output is correct |
4 |
Correct |
172 ms |
58812 KB |
Output is correct |
5 |
Correct |
162 ms |
58716 KB |
Output is correct |
6 |
Correct |
169 ms |
58716 KB |
Output is correct |
7 |
Correct |
179 ms |
58812 KB |
Output is correct |
8 |
Correct |
176 ms |
58848 KB |
Output is correct |
9 |
Correct |
180 ms |
58688 KB |
Output is correct |
10 |
Correct |
178 ms |
58796 KB |
Output is correct |
11 |
Correct |
177 ms |
58756 KB |
Output is correct |
12 |
Correct |
168 ms |
58732 KB |
Output is correct |
13 |
Correct |
191 ms |
58792 KB |
Output is correct |
14 |
Correct |
170 ms |
58820 KB |
Output is correct |
15 |
Correct |
178 ms |
58792 KB |
Output is correct |
16 |
Correct |
177 ms |
58732 KB |
Output is correct |
17 |
Correct |
182 ms |
58788 KB |
Output is correct |
18 |
Correct |
172 ms |
58820 KB |
Output is correct |
19 |
Correct |
218 ms |
58792 KB |
Output is correct |
20 |
Correct |
198 ms |
58812 KB |
Output is correct |
21 |
Correct |
185 ms |
58760 KB |
Output is correct |
22 |
Correct |
173 ms |
58820 KB |
Output is correct |
23 |
Correct |
185 ms |
58752 KB |
Output is correct |
24 |
Correct |
178 ms |
58796 KB |
Output is correct |
25 |
Correct |
187 ms |
58824 KB |
Output is correct |
26 |
Correct |
171 ms |
58816 KB |
Output is correct |
27 |
Correct |
183 ms |
58792 KB |
Output is correct |
28 |
Correct |
173 ms |
58820 KB |
Output is correct |
29 |
Correct |
195 ms |
58820 KB |
Output is correct |
30 |
Correct |
169 ms |
58764 KB |
Output is correct |
31 |
Incorrect |
184 ms |
58800 KB |
Output isn't correct |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
184 ms |
58752 KB |
Output is correct |
2 |
Correct |
197 ms |
58780 KB |
Output is correct |
3 |
Correct |
185 ms |
58736 KB |
Output is correct |
4 |
Correct |
172 ms |
58812 KB |
Output is correct |
5 |
Correct |
162 ms |
58716 KB |
Output is correct |
6 |
Correct |
169 ms |
58716 KB |
Output is correct |
7 |
Correct |
179 ms |
58812 KB |
Output is correct |
8 |
Correct |
176 ms |
58848 KB |
Output is correct |
9 |
Correct |
180 ms |
58688 KB |
Output is correct |
10 |
Correct |
178 ms |
58796 KB |
Output is correct |
11 |
Correct |
177 ms |
58756 KB |
Output is correct |
12 |
Correct |
168 ms |
58732 KB |
Output is correct |
13 |
Correct |
191 ms |
58792 KB |
Output is correct |
14 |
Correct |
170 ms |
58820 KB |
Output is correct |
15 |
Correct |
178 ms |
58792 KB |
Output is correct |
16 |
Correct |
177 ms |
58732 KB |
Output is correct |
17 |
Correct |
182 ms |
58788 KB |
Output is correct |
18 |
Correct |
172 ms |
58820 KB |
Output is correct |
19 |
Correct |
1100 ms |
87784 KB |
Output is correct |
20 |
Correct |
811 ms |
87800 KB |
Output is correct |
21 |
Correct |
717 ms |
87192 KB |
Output is correct |
22 |
Correct |
706 ms |
86140 KB |
Output is correct |
23 |
Correct |
323 ms |
60480 KB |
Output is correct |
24 |
Correct |
322 ms |
60496 KB |
Output is correct |
25 |
Correct |
772 ms |
87784 KB |
Output is correct |
26 |
Correct |
805 ms |
87792 KB |
Output is correct |
27 |
Correct |
922 ms |
87804 KB |
Output is correct |
28 |
Correct |
921 ms |
87788 KB |
Output is correct |
29 |
Correct |
839 ms |
87528 KB |
Output is correct |
30 |
Correct |
368 ms |
60484 KB |
Output is correct |
31 |
Correct |
851 ms |
87772 KB |
Output is correct |
32 |
Correct |
809 ms |
86964 KB |
Output is correct |
33 |
Correct |
326 ms |
60428 KB |
Output is correct |
34 |
Correct |
868 ms |
87828 KB |
Output is correct |
35 |
Correct |
628 ms |
85116 KB |
Output is correct |
36 |
Correct |
319 ms |
60484 KB |
Output is correct |
37 |
Correct |
316 ms |
60596 KB |
Output is correct |
38 |
Correct |
680 ms |
87788 KB |
Output is correct |
39 |
Correct |
363 ms |
87896 KB |
Output is correct |
40 |
Correct |
662 ms |
75036 KB |
Output is correct |
41 |
Correct |
1152 ms |
87656 KB |
Output is correct |
42 |
Correct |
110 ms |
87800 KB |
Output is correct |
43 |
Correct |
218 ms |
58792 KB |
Output is correct |
44 |
Correct |
198 ms |
58812 KB |
Output is correct |
45 |
Correct |
185 ms |
58760 KB |
Output is correct |
46 |
Correct |
173 ms |
58820 KB |
Output is correct |
47 |
Correct |
185 ms |
58752 KB |
Output is correct |
48 |
Correct |
178 ms |
58796 KB |
Output is correct |
49 |
Correct |
187 ms |
58824 KB |
Output is correct |
50 |
Correct |
171 ms |
58816 KB |
Output is correct |
51 |
Correct |
183 ms |
58792 KB |
Output is correct |
52 |
Correct |
173 ms |
58820 KB |
Output is correct |
53 |
Correct |
195 ms |
58820 KB |
Output is correct |
54 |
Correct |
169 ms |
58764 KB |
Output is correct |
55 |
Incorrect |
184 ms |
58800 KB |
Output isn't correct |
56 |
Halted |
0 ms |
0 KB |
- |