# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
445970 |
2021-07-20T09:59:57 Z |
dutch |
Crossing (JOI21_crossing) |
C++17 |
|
1830 ms |
37576 KB |
#include <bits/stdc++.h>
using namespace std;
#define get(c) (c == 'I' ? 2 : c == 'O')
const int LIM = 1<<18;
int n, q, l, r, p[3][9][LIM];
string s[10];
short a[2*LIM], v;
bool b[9][2*LIM];
void pull(int x, int lx, int rx){
for(int i=0; i<9; ++i){
if(a[x] == 3){
assert(2*x+2 < 2*LIM);
b[i][x] = b[i][2*x+1] && b[i][2*x+2];
}else{
int sum = p[a[x]][i][rx-1] - (lx ? p[a[x]][i][lx-1] : 0);
b[i][x] = sum == rx - lx;
}
}
}
void build(int x, int lx, int rx){
if(rx - lx < 2){
a[x] = get(s[9][lx]);
pull(x, lx, rx);
return;
}
int mx = (lx + rx) / 2;
build(2*x+1, lx, mx);
build(2*x+2, mx, rx);
pull(x, lx, rx);
}
void rangeAssign(int x, int lx, int rx){
if(r<=lx || rx<=l) return;
if(l<=lx && rx<=r){
a[x] = v;
pull(x, lx, rx);
return;
}
int mx = (lx + rx) / 2;
if(a[x] < 3){
a[2*x+1] = a[2*x+2] = a[x];
a[x] = 3;
pull(2*x+1, lx, mx);
pull(2*x+2, mx, rx);
pull(x, lx, rx);
}
rangeAssign(2*x+1, lx, mx);
rangeAssign(2*x+2, mx, rx);
pull(x, lx, rx);
}
void print(){
for(int i=0; i<9; ++i) if(b[i][0]) return void(cout << "Yes\n");
cout << "No\n";
}
string comb(string &x, string &y){
string z(n, 0);
for(int i=0; i<n; ++i){
z[i] = x[i] == y[i] ? x[i] : 226 - x[i] - y[i];
}
return z;
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
cin >> n;
cin >> s[0] >> s[1] >> s[2];
s[3] = comb(s[1], s[2]);
s[4] = comb(s[0], s[2]);
s[5] = comb(s[0], s[1]);
for(int i=0; i<3; ++i){
s[6+i] = comb(s[i], s[3+i]);
}
fill(a, a+2*LIM, 3);
cin >> q >> s[9];
for(int i=0; i<10; ++i){
s[i] += string(LIM-n, 'J');
}
for(int i=0; i<3; ++i){
for(int j=0; j<9; ++j){
int pre = 0;
for(int k=0; k<LIM; ++k){
pre += get(s[j][k]) == i;
p[i][j][k] = pre;
}
}
}
build(0, 0, LIM);
char inp;
print();
while(q--){
cin >> l >> r >> inp;
--l; v = get(inp);
rangeAssign(0, 0, LIM);
print();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
460 ms |
37244 KB |
Output is correct |
2 |
Correct |
512 ms |
37272 KB |
Output is correct |
3 |
Correct |
537 ms |
37316 KB |
Output is correct |
4 |
Correct |
408 ms |
37252 KB |
Output is correct |
5 |
Correct |
402 ms |
37240 KB |
Output is correct |
6 |
Correct |
396 ms |
37376 KB |
Output is correct |
7 |
Correct |
416 ms |
37352 KB |
Output is correct |
8 |
Correct |
414 ms |
37288 KB |
Output is correct |
9 |
Correct |
419 ms |
37280 KB |
Output is correct |
10 |
Correct |
418 ms |
37316 KB |
Output is correct |
11 |
Correct |
414 ms |
37196 KB |
Output is correct |
12 |
Correct |
407 ms |
37292 KB |
Output is correct |
13 |
Correct |
412 ms |
37312 KB |
Output is correct |
14 |
Correct |
411 ms |
37284 KB |
Output is correct |
15 |
Correct |
431 ms |
37344 KB |
Output is correct |
16 |
Correct |
409 ms |
37240 KB |
Output is correct |
17 |
Correct |
415 ms |
37440 KB |
Output is correct |
18 |
Correct |
528 ms |
37404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
460 ms |
37244 KB |
Output is correct |
2 |
Correct |
512 ms |
37272 KB |
Output is correct |
3 |
Correct |
537 ms |
37316 KB |
Output is correct |
4 |
Correct |
408 ms |
37252 KB |
Output is correct |
5 |
Correct |
402 ms |
37240 KB |
Output is correct |
6 |
Correct |
396 ms |
37376 KB |
Output is correct |
7 |
Correct |
416 ms |
37352 KB |
Output is correct |
8 |
Correct |
414 ms |
37288 KB |
Output is correct |
9 |
Correct |
419 ms |
37280 KB |
Output is correct |
10 |
Correct |
418 ms |
37316 KB |
Output is correct |
11 |
Correct |
414 ms |
37196 KB |
Output is correct |
12 |
Correct |
407 ms |
37292 KB |
Output is correct |
13 |
Correct |
412 ms |
37312 KB |
Output is correct |
14 |
Correct |
411 ms |
37284 KB |
Output is correct |
15 |
Correct |
431 ms |
37344 KB |
Output is correct |
16 |
Correct |
409 ms |
37240 KB |
Output is correct |
17 |
Correct |
415 ms |
37440 KB |
Output is correct |
18 |
Correct |
528 ms |
37404 KB |
Output is correct |
19 |
Correct |
1655 ms |
37224 KB |
Output is correct |
20 |
Correct |
1415 ms |
37084 KB |
Output is correct |
21 |
Correct |
565 ms |
37376 KB |
Output is correct |
22 |
Correct |
624 ms |
37132 KB |
Output is correct |
23 |
Correct |
402 ms |
37228 KB |
Output is correct |
24 |
Correct |
444 ms |
37436 KB |
Output is correct |
25 |
Correct |
594 ms |
37116 KB |
Output is correct |
26 |
Correct |
680 ms |
37148 KB |
Output is correct |
27 |
Correct |
888 ms |
37172 KB |
Output is correct |
28 |
Correct |
886 ms |
37160 KB |
Output is correct |
29 |
Correct |
816 ms |
37304 KB |
Output is correct |
30 |
Correct |
538 ms |
37128 KB |
Output is correct |
31 |
Correct |
841 ms |
37252 KB |
Output is correct |
32 |
Correct |
778 ms |
37168 KB |
Output is correct |
33 |
Correct |
422 ms |
37328 KB |
Output is correct |
34 |
Correct |
842 ms |
37144 KB |
Output is correct |
35 |
Correct |
525 ms |
37096 KB |
Output is correct |
36 |
Correct |
395 ms |
37420 KB |
Output is correct |
37 |
Correct |
408 ms |
37432 KB |
Output is correct |
38 |
Correct |
1325 ms |
37448 KB |
Output is correct |
39 |
Correct |
375 ms |
37104 KB |
Output is correct |
40 |
Correct |
569 ms |
37424 KB |
Output is correct |
41 |
Correct |
1830 ms |
37424 KB |
Output is correct |
42 |
Correct |
287 ms |
37356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
460 ms |
37244 KB |
Output is correct |
2 |
Correct |
512 ms |
37272 KB |
Output is correct |
3 |
Correct |
537 ms |
37316 KB |
Output is correct |
4 |
Correct |
408 ms |
37252 KB |
Output is correct |
5 |
Correct |
402 ms |
37240 KB |
Output is correct |
6 |
Correct |
396 ms |
37376 KB |
Output is correct |
7 |
Correct |
416 ms |
37352 KB |
Output is correct |
8 |
Correct |
414 ms |
37288 KB |
Output is correct |
9 |
Correct |
419 ms |
37280 KB |
Output is correct |
10 |
Correct |
418 ms |
37316 KB |
Output is correct |
11 |
Correct |
414 ms |
37196 KB |
Output is correct |
12 |
Correct |
407 ms |
37292 KB |
Output is correct |
13 |
Correct |
412 ms |
37312 KB |
Output is correct |
14 |
Correct |
411 ms |
37284 KB |
Output is correct |
15 |
Correct |
431 ms |
37344 KB |
Output is correct |
16 |
Correct |
409 ms |
37240 KB |
Output is correct |
17 |
Correct |
415 ms |
37440 KB |
Output is correct |
18 |
Correct |
528 ms |
37404 KB |
Output is correct |
19 |
Correct |
460 ms |
37188 KB |
Output is correct |
20 |
Correct |
562 ms |
37432 KB |
Output is correct |
21 |
Correct |
398 ms |
37296 KB |
Output is correct |
22 |
Correct |
376 ms |
37380 KB |
Output is correct |
23 |
Correct |
415 ms |
37392 KB |
Output is correct |
24 |
Correct |
433 ms |
37200 KB |
Output is correct |
25 |
Correct |
444 ms |
37364 KB |
Output is correct |
26 |
Correct |
406 ms |
37344 KB |
Output is correct |
27 |
Correct |
443 ms |
37368 KB |
Output is correct |
28 |
Correct |
391 ms |
37188 KB |
Output is correct |
29 |
Correct |
409 ms |
37312 KB |
Output is correct |
30 |
Correct |
382 ms |
37256 KB |
Output is correct |
31 |
Correct |
428 ms |
37268 KB |
Output is correct |
32 |
Correct |
407 ms |
37312 KB |
Output is correct |
33 |
Correct |
411 ms |
37244 KB |
Output is correct |
34 |
Correct |
388 ms |
37248 KB |
Output is correct |
35 |
Correct |
406 ms |
37244 KB |
Output is correct |
36 |
Correct |
420 ms |
37324 KB |
Output is correct |
37 |
Correct |
404 ms |
37224 KB |
Output is correct |
38 |
Correct |
415 ms |
37200 KB |
Output is correct |
39 |
Correct |
406 ms |
37228 KB |
Output is correct |
40 |
Correct |
441 ms |
37308 KB |
Output is correct |
41 |
Correct |
407 ms |
37252 KB |
Output is correct |
42 |
Correct |
414 ms |
37348 KB |
Output is correct |
43 |
Correct |
441 ms |
37256 KB |
Output is correct |
44 |
Correct |
413 ms |
37292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
460 ms |
37244 KB |
Output is correct |
2 |
Correct |
512 ms |
37272 KB |
Output is correct |
3 |
Correct |
537 ms |
37316 KB |
Output is correct |
4 |
Correct |
408 ms |
37252 KB |
Output is correct |
5 |
Correct |
402 ms |
37240 KB |
Output is correct |
6 |
Correct |
396 ms |
37376 KB |
Output is correct |
7 |
Correct |
416 ms |
37352 KB |
Output is correct |
8 |
Correct |
414 ms |
37288 KB |
Output is correct |
9 |
Correct |
419 ms |
37280 KB |
Output is correct |
10 |
Correct |
418 ms |
37316 KB |
Output is correct |
11 |
Correct |
414 ms |
37196 KB |
Output is correct |
12 |
Correct |
407 ms |
37292 KB |
Output is correct |
13 |
Correct |
412 ms |
37312 KB |
Output is correct |
14 |
Correct |
411 ms |
37284 KB |
Output is correct |
15 |
Correct |
431 ms |
37344 KB |
Output is correct |
16 |
Correct |
409 ms |
37240 KB |
Output is correct |
17 |
Correct |
415 ms |
37440 KB |
Output is correct |
18 |
Correct |
528 ms |
37404 KB |
Output is correct |
19 |
Correct |
1655 ms |
37224 KB |
Output is correct |
20 |
Correct |
1415 ms |
37084 KB |
Output is correct |
21 |
Correct |
565 ms |
37376 KB |
Output is correct |
22 |
Correct |
624 ms |
37132 KB |
Output is correct |
23 |
Correct |
402 ms |
37228 KB |
Output is correct |
24 |
Correct |
444 ms |
37436 KB |
Output is correct |
25 |
Correct |
594 ms |
37116 KB |
Output is correct |
26 |
Correct |
680 ms |
37148 KB |
Output is correct |
27 |
Correct |
888 ms |
37172 KB |
Output is correct |
28 |
Correct |
886 ms |
37160 KB |
Output is correct |
29 |
Correct |
816 ms |
37304 KB |
Output is correct |
30 |
Correct |
538 ms |
37128 KB |
Output is correct |
31 |
Correct |
841 ms |
37252 KB |
Output is correct |
32 |
Correct |
778 ms |
37168 KB |
Output is correct |
33 |
Correct |
422 ms |
37328 KB |
Output is correct |
34 |
Correct |
842 ms |
37144 KB |
Output is correct |
35 |
Correct |
525 ms |
37096 KB |
Output is correct |
36 |
Correct |
395 ms |
37420 KB |
Output is correct |
37 |
Correct |
408 ms |
37432 KB |
Output is correct |
38 |
Correct |
1325 ms |
37448 KB |
Output is correct |
39 |
Correct |
375 ms |
37104 KB |
Output is correct |
40 |
Correct |
569 ms |
37424 KB |
Output is correct |
41 |
Correct |
1830 ms |
37424 KB |
Output is correct |
42 |
Correct |
287 ms |
37356 KB |
Output is correct |
43 |
Correct |
460 ms |
37188 KB |
Output is correct |
44 |
Correct |
562 ms |
37432 KB |
Output is correct |
45 |
Correct |
398 ms |
37296 KB |
Output is correct |
46 |
Correct |
376 ms |
37380 KB |
Output is correct |
47 |
Correct |
415 ms |
37392 KB |
Output is correct |
48 |
Correct |
433 ms |
37200 KB |
Output is correct |
49 |
Correct |
444 ms |
37364 KB |
Output is correct |
50 |
Correct |
406 ms |
37344 KB |
Output is correct |
51 |
Correct |
443 ms |
37368 KB |
Output is correct |
52 |
Correct |
391 ms |
37188 KB |
Output is correct |
53 |
Correct |
409 ms |
37312 KB |
Output is correct |
54 |
Correct |
382 ms |
37256 KB |
Output is correct |
55 |
Correct |
428 ms |
37268 KB |
Output is correct |
56 |
Correct |
407 ms |
37312 KB |
Output is correct |
57 |
Correct |
411 ms |
37244 KB |
Output is correct |
58 |
Correct |
388 ms |
37248 KB |
Output is correct |
59 |
Correct |
406 ms |
37244 KB |
Output is correct |
60 |
Correct |
420 ms |
37324 KB |
Output is correct |
61 |
Correct |
404 ms |
37224 KB |
Output is correct |
62 |
Correct |
415 ms |
37200 KB |
Output is correct |
63 |
Correct |
406 ms |
37228 KB |
Output is correct |
64 |
Correct |
441 ms |
37308 KB |
Output is correct |
65 |
Correct |
407 ms |
37252 KB |
Output is correct |
66 |
Correct |
414 ms |
37348 KB |
Output is correct |
67 |
Correct |
441 ms |
37256 KB |
Output is correct |
68 |
Correct |
413 ms |
37292 KB |
Output is correct |
69 |
Correct |
1374 ms |
37104 KB |
Output is correct |
70 |
Correct |
1546 ms |
37140 KB |
Output is correct |
71 |
Correct |
408 ms |
37452 KB |
Output is correct |
72 |
Correct |
435 ms |
37204 KB |
Output is correct |
73 |
Correct |
427 ms |
37284 KB |
Output is correct |
74 |
Correct |
544 ms |
37576 KB |
Output is correct |
75 |
Correct |
400 ms |
37320 KB |
Output is correct |
76 |
Correct |
601 ms |
37180 KB |
Output is correct |
77 |
Correct |
663 ms |
37168 KB |
Output is correct |
78 |
Correct |
429 ms |
37324 KB |
Output is correct |
79 |
Correct |
406 ms |
37184 KB |
Output is correct |
80 |
Correct |
625 ms |
37148 KB |
Output is correct |
81 |
Correct |
408 ms |
37408 KB |
Output is correct |
82 |
Correct |
612 ms |
37268 KB |
Output is correct |
83 |
Correct |
666 ms |
37136 KB |
Output is correct |
84 |
Correct |
415 ms |
37452 KB |
Output is correct |
85 |
Correct |
407 ms |
37460 KB |
Output is correct |
86 |
Correct |
950 ms |
37316 KB |
Output is correct |
87 |
Correct |
911 ms |
37200 KB |
Output is correct |
88 |
Correct |
488 ms |
37280 KB |
Output is correct |
89 |
Correct |
764 ms |
37092 KB |
Output is correct |
90 |
Correct |
829 ms |
37140 KB |
Output is correct |
91 |
Correct |
465 ms |
37440 KB |
Output is correct |
92 |
Correct |
533 ms |
37120 KB |
Output is correct |
93 |
Correct |
416 ms |
37360 KB |
Output is correct |
94 |
Correct |
414 ms |
37400 KB |
Output is correct |
95 |
Correct |
410 ms |
37320 KB |
Output is correct |
96 |
Correct |
1318 ms |
37264 KB |
Output is correct |
97 |
Correct |
362 ms |
37224 KB |
Output is correct |
98 |
Correct |
573 ms |
37284 KB |
Output is correct |
99 |
Correct |
1749 ms |
37296 KB |
Output is correct |
100 |
Correct |
298 ms |
37296 KB |
Output is correct |