#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define boost() cin.tie(0), cin.sync_with_stdio(0)
#define mid ((l + r) / 2)
const int MN = 200005;
int n, a[MN], b[MN], c[MN], d[MN], q, l, r, lzy[MN * 4], st[MN * 4][3][3];
char ch;
int g(char x) {
if (x == 'J') return 0;
if (x == 'O') return 1;
return 2;
}
void push_down(int l, int r, int idx) {
if (lzy[idx] == -1) return;
for (int i = 0; i < 3; i++) {
int cnt = 0;
for (int j = 0; j < 3; j++) {
cnt += st[idx][i][j];
st[idx][i][j] = 0;
}
st[idx][i][lzy[idx]] = cnt;
}
if (l != r) lzy[idx * 2] = lzy[idx * 2 + 1] = lzy[idx];
lzy[idx] = -1;
}
void build(int l, int r, int idx) {
lzy[idx] = -1;
if (l == r) {
st[idx][a[l]][d[l]]++;
return;
}
build(l, mid, idx * 2), build(mid + 1, r, idx * 2 + 1);
for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) st[idx][i][j] = st[idx * 2][i][j] + st[idx * 2 + 1][i][j];
}
void upd(int l, int r, int x, int y, int val, int idx) {
push_down(l, r, idx);
if (r < x || l > y) return;
if (r <= y && l >= x) {
lzy[idx] = val;
push_down(l, r, idx);
return;
}
upd(l, mid, x, y, val, idx * 2), upd(mid + 1, r, x, y, val, idx * 2 + 1);
for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) st[idx][i][j] = st[idx * 2][i][j] + st[idx * 2 + 1][i][j];
}
void check() {
if (st[1][0][0] + st[1][1][1] + st[1][2][2] == n) printf("Yes\n");
else printf("No\n");
}
int32_t main() {
boost();
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> ch;
a[i] = g(ch);
}
for (int i = 1; i <= n; i++) {
cin >> ch;
b[i] = g(ch);
}
for (int i = 1; i <= n; i++) {
cin >> ch;
c[i] = g(ch);
}
cin >> q;
for (int i = 1; i <= n; i++) {
cin >> ch;
d[i] = g(ch);
}
build(1, n, 1);
check();
while (q--) {
cin >> l >> r >> ch;
int val = g(ch);
upd(1, n, l, r, val, 1);
check();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
2244 KB |
Output is correct |
2 |
Correct |
81 ms |
2444 KB |
Output is correct |
3 |
Correct |
84 ms |
2272 KB |
Output is correct |
4 |
Correct |
64 ms |
2356 KB |
Output is correct |
5 |
Correct |
68 ms |
2316 KB |
Output is correct |
6 |
Correct |
71 ms |
2240 KB |
Output is correct |
7 |
Correct |
70 ms |
2428 KB |
Output is correct |
8 |
Correct |
76 ms |
2404 KB |
Output is correct |
9 |
Correct |
74 ms |
2372 KB |
Output is correct |
10 |
Correct |
74 ms |
2372 KB |
Output is correct |
11 |
Correct |
76 ms |
2384 KB |
Output is correct |
12 |
Correct |
72 ms |
2424 KB |
Output is correct |
13 |
Correct |
72 ms |
2372 KB |
Output is correct |
14 |
Correct |
72 ms |
2420 KB |
Output is correct |
15 |
Correct |
78 ms |
2388 KB |
Output is correct |
16 |
Correct |
77 ms |
2472 KB |
Output is correct |
17 |
Correct |
73 ms |
2372 KB |
Output is correct |
18 |
Correct |
80 ms |
2372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
2244 KB |
Output is correct |
2 |
Correct |
81 ms |
2444 KB |
Output is correct |
3 |
Correct |
84 ms |
2272 KB |
Output is correct |
4 |
Correct |
64 ms |
2356 KB |
Output is correct |
5 |
Correct |
68 ms |
2316 KB |
Output is correct |
6 |
Correct |
71 ms |
2240 KB |
Output is correct |
7 |
Correct |
70 ms |
2428 KB |
Output is correct |
8 |
Correct |
76 ms |
2404 KB |
Output is correct |
9 |
Correct |
74 ms |
2372 KB |
Output is correct |
10 |
Correct |
74 ms |
2372 KB |
Output is correct |
11 |
Correct |
76 ms |
2384 KB |
Output is correct |
12 |
Correct |
72 ms |
2424 KB |
Output is correct |
13 |
Correct |
72 ms |
2372 KB |
Output is correct |
14 |
Correct |
72 ms |
2420 KB |
Output is correct |
15 |
Correct |
78 ms |
2388 KB |
Output is correct |
16 |
Correct |
77 ms |
2472 KB |
Output is correct |
17 |
Correct |
73 ms |
2372 KB |
Output is correct |
18 |
Correct |
80 ms |
2372 KB |
Output is correct |
19 |
Correct |
364 ms |
52040 KB |
Output is correct |
20 |
Correct |
314 ms |
51796 KB |
Output is correct |
21 |
Correct |
233 ms |
51272 KB |
Output is correct |
22 |
Correct |
232 ms |
50424 KB |
Output is correct |
23 |
Correct |
122 ms |
6088 KB |
Output is correct |
24 |
Correct |
122 ms |
6076 KB |
Output is correct |
25 |
Correct |
242 ms |
51908 KB |
Output is correct |
26 |
Correct |
261 ms |
51908 KB |
Output is correct |
27 |
Correct |
335 ms |
51948 KB |
Output is correct |
28 |
Correct |
293 ms |
51796 KB |
Output is correct |
29 |
Correct |
268 ms |
51552 KB |
Output is correct |
30 |
Correct |
127 ms |
6164 KB |
Output is correct |
31 |
Correct |
283 ms |
52016 KB |
Output is correct |
32 |
Correct |
268 ms |
51072 KB |
Output is correct |
33 |
Correct |
121 ms |
6136 KB |
Output is correct |
34 |
Correct |
283 ms |
51944 KB |
Output is correct |
35 |
Correct |
210 ms |
49732 KB |
Output is correct |
36 |
Correct |
119 ms |
6132 KB |
Output is correct |
37 |
Correct |
123 ms |
6104 KB |
Output is correct |
38 |
Correct |
262 ms |
51624 KB |
Output is correct |
39 |
Correct |
163 ms |
51968 KB |
Output is correct |
40 |
Correct |
238 ms |
28856 KB |
Output is correct |
41 |
Correct |
436 ms |
52040 KB |
Output is correct |
42 |
Correct |
69 ms |
51268 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
2244 KB |
Output is correct |
2 |
Correct |
81 ms |
2444 KB |
Output is correct |
3 |
Correct |
84 ms |
2272 KB |
Output is correct |
4 |
Correct |
64 ms |
2356 KB |
Output is correct |
5 |
Correct |
68 ms |
2316 KB |
Output is correct |
6 |
Correct |
71 ms |
2240 KB |
Output is correct |
7 |
Correct |
70 ms |
2428 KB |
Output is correct |
8 |
Correct |
76 ms |
2404 KB |
Output is correct |
9 |
Correct |
74 ms |
2372 KB |
Output is correct |
10 |
Correct |
74 ms |
2372 KB |
Output is correct |
11 |
Correct |
76 ms |
2384 KB |
Output is correct |
12 |
Correct |
72 ms |
2424 KB |
Output is correct |
13 |
Correct |
72 ms |
2372 KB |
Output is correct |
14 |
Correct |
72 ms |
2420 KB |
Output is correct |
15 |
Correct |
78 ms |
2388 KB |
Output is correct |
16 |
Correct |
77 ms |
2472 KB |
Output is correct |
17 |
Correct |
73 ms |
2372 KB |
Output is correct |
18 |
Correct |
80 ms |
2372 KB |
Output is correct |
19 |
Correct |
81 ms |
2304 KB |
Output is correct |
20 |
Correct |
83 ms |
2368 KB |
Output is correct |
21 |
Incorrect |
72 ms |
2488 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
2244 KB |
Output is correct |
2 |
Correct |
81 ms |
2444 KB |
Output is correct |
3 |
Correct |
84 ms |
2272 KB |
Output is correct |
4 |
Correct |
64 ms |
2356 KB |
Output is correct |
5 |
Correct |
68 ms |
2316 KB |
Output is correct |
6 |
Correct |
71 ms |
2240 KB |
Output is correct |
7 |
Correct |
70 ms |
2428 KB |
Output is correct |
8 |
Correct |
76 ms |
2404 KB |
Output is correct |
9 |
Correct |
74 ms |
2372 KB |
Output is correct |
10 |
Correct |
74 ms |
2372 KB |
Output is correct |
11 |
Correct |
76 ms |
2384 KB |
Output is correct |
12 |
Correct |
72 ms |
2424 KB |
Output is correct |
13 |
Correct |
72 ms |
2372 KB |
Output is correct |
14 |
Correct |
72 ms |
2420 KB |
Output is correct |
15 |
Correct |
78 ms |
2388 KB |
Output is correct |
16 |
Correct |
77 ms |
2472 KB |
Output is correct |
17 |
Correct |
73 ms |
2372 KB |
Output is correct |
18 |
Correct |
80 ms |
2372 KB |
Output is correct |
19 |
Correct |
364 ms |
52040 KB |
Output is correct |
20 |
Correct |
314 ms |
51796 KB |
Output is correct |
21 |
Correct |
233 ms |
51272 KB |
Output is correct |
22 |
Correct |
232 ms |
50424 KB |
Output is correct |
23 |
Correct |
122 ms |
6088 KB |
Output is correct |
24 |
Correct |
122 ms |
6076 KB |
Output is correct |
25 |
Correct |
242 ms |
51908 KB |
Output is correct |
26 |
Correct |
261 ms |
51908 KB |
Output is correct |
27 |
Correct |
335 ms |
51948 KB |
Output is correct |
28 |
Correct |
293 ms |
51796 KB |
Output is correct |
29 |
Correct |
268 ms |
51552 KB |
Output is correct |
30 |
Correct |
127 ms |
6164 KB |
Output is correct |
31 |
Correct |
283 ms |
52016 KB |
Output is correct |
32 |
Correct |
268 ms |
51072 KB |
Output is correct |
33 |
Correct |
121 ms |
6136 KB |
Output is correct |
34 |
Correct |
283 ms |
51944 KB |
Output is correct |
35 |
Correct |
210 ms |
49732 KB |
Output is correct |
36 |
Correct |
119 ms |
6132 KB |
Output is correct |
37 |
Correct |
123 ms |
6104 KB |
Output is correct |
38 |
Correct |
262 ms |
51624 KB |
Output is correct |
39 |
Correct |
163 ms |
51968 KB |
Output is correct |
40 |
Correct |
238 ms |
28856 KB |
Output is correct |
41 |
Correct |
436 ms |
52040 KB |
Output is correct |
42 |
Correct |
69 ms |
51268 KB |
Output is correct |
43 |
Correct |
81 ms |
2304 KB |
Output is correct |
44 |
Correct |
83 ms |
2368 KB |
Output is correct |
45 |
Incorrect |
72 ms |
2488 KB |
Output isn't correct |
46 |
Halted |
0 ms |
0 KB |
- |