# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1050599 |
2024-08-09T11:40:00 Z |
Andrey |
Crossing (JOI21_crossing) |
C++14 |
|
161 ms |
34132 KB |
#include<bits/stdc++.h>
using namespace std;
int troll(char a) {
if(a == 'J') {
return 0;
}
else if(a == 'O') {
return 1;
}
else {
return 2;
}
}
vector<int> seg(1000001);
vector<pair<int,int>> wow(1000001,{-2,-1});
vector<int> banana(1000001,-1);
int idk[1000001][3];
int no[9][3] = {{0,0,1},{0,1,0},{1,0,0},{2,2,0},{2,0,2},{0,2,2},{1,1,2},{1,2,1},{2,1,1}};
int pr[200001][3];
vector<int> a(200001);
vector<int> b(200001);
vector<int> c(200001);
vector<int> s(200001);
void upd(int l, int r, int ql, int qr, int x, int col, pair<int,int> z, int t) {
if(l == ql && r == qr) {
seg[x] = idk[x][col];
wow[x] = {t,col};
banana[x] = t;
return;
}
int mid = (l+r)/2;
z = max(z,wow[x]);
if(qr <= mid) {
upd(l,mid,ql,qr,x*2,col,z,t);
}
else if(ql > mid) {
upd(mid+1,r,ql,qr,x*2+1,col,z,t);
}
else {
upd(l,mid,ql,mid,x*2,col,z,t);
upd(mid+1,r,mid+1,qr,x*2+1,col,z,t);
}
int a,b;
if(z.first > banana[x*2]) {
a = idk[x*2][z.second];
}
else {
a = seg[x*2];
}
if(z.first > banana[x*2+1]) {
b = idk[x*2+1][z.second];
}
else {
b = seg[x*2+1];
}
seg[x] = (a&b);
banana[x] = t;
}
void build(int l, int r, int x) {
if(l == r) {
seg[x] = pr[l][s[l]];
idk[x][0] = pr[l][0];
idk[x][1] = pr[l][1];
idk[x][2] = pr[l][2];
return;
}
int mid = (l+r)/2;
build(l,mid,x*2);
build(mid+1,r,x*2+1);
idk[x][0] = (idk[x*2][0]&idk[x*2+1][0]);
idk[x][1] = (idk[x*2][1]&idk[x*2+1][1]);
idk[x][2] = (idk[x*2][2]&idk[x*2+1][2]);
seg[x] = (seg[x*2]&seg[x*2+1]);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,q;
cin >> n;
char x;
for(int i = 0; i <= n; i++) {
for(int j = 0; j < 3; j++) {
pr[i][j] = 0;
}
}
for(int i = 1; i <= n; i++) {
cin >> x;
a[i] = troll(x);
}
for(int i = 1; i <= n; i++) {
cin >> x;
b[i] = troll(x);
}
for(int i = 1; i <= n; i++) {
cin >> x;
c[i] = troll(x);
}
cin >> q;
for(int i = 1; i <= n; i++) {
cin >> x;
s[i] = troll(x);
}
for(int i = 1; i <= n; i++) {
for(int j = 0; j < 9; j++) {
int br = (a[i]*no[j][0]+b[i]*no[j][1]+c[i]*no[j][2])%3;
pr[i][br]+=(1 << j);
}
}
build(1,n,1);
if(seg[1] > 0) {
cout << "Yes\n";
}
else {
cout << "No\n";
}
for(int i = 0; i < q; i++) {
int l,r;
cin >> l >> r >> x;
int br = troll(x);
upd(1,n,l,r,1,br,{-1,-1},i);
if(seg[1] > 0) {
cout << "Yes\n";
}
else {
cout << "No\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
21848 KB |
Output is correct |
2 |
Correct |
39 ms |
21904 KB |
Output is correct |
3 |
Correct |
38 ms |
19864 KB |
Output is correct |
4 |
Correct |
57 ms |
19740 KB |
Output is correct |
5 |
Correct |
38 ms |
23128 KB |
Output is correct |
6 |
Correct |
40 ms |
23164 KB |
Output is correct |
7 |
Correct |
38 ms |
23388 KB |
Output is correct |
8 |
Correct |
38 ms |
21328 KB |
Output is correct |
9 |
Correct |
41 ms |
21248 KB |
Output is correct |
10 |
Correct |
39 ms |
21340 KB |
Output is correct |
11 |
Correct |
61 ms |
23372 KB |
Output is correct |
12 |
Correct |
38 ms |
23272 KB |
Output is correct |
13 |
Correct |
39 ms |
23440 KB |
Output is correct |
14 |
Correct |
39 ms |
23328 KB |
Output is correct |
15 |
Correct |
61 ms |
23288 KB |
Output is correct |
16 |
Correct |
56 ms |
21376 KB |
Output is correct |
17 |
Correct |
38 ms |
23380 KB |
Output is correct |
18 |
Correct |
39 ms |
23360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
21848 KB |
Output is correct |
2 |
Correct |
39 ms |
21904 KB |
Output is correct |
3 |
Correct |
38 ms |
19864 KB |
Output is correct |
4 |
Correct |
57 ms |
19740 KB |
Output is correct |
5 |
Correct |
38 ms |
23128 KB |
Output is correct |
6 |
Correct |
40 ms |
23164 KB |
Output is correct |
7 |
Correct |
38 ms |
23388 KB |
Output is correct |
8 |
Correct |
38 ms |
21328 KB |
Output is correct |
9 |
Correct |
41 ms |
21248 KB |
Output is correct |
10 |
Correct |
39 ms |
21340 KB |
Output is correct |
11 |
Correct |
61 ms |
23372 KB |
Output is correct |
12 |
Correct |
38 ms |
23272 KB |
Output is correct |
13 |
Correct |
39 ms |
23440 KB |
Output is correct |
14 |
Correct |
39 ms |
23328 KB |
Output is correct |
15 |
Correct |
61 ms |
23288 KB |
Output is correct |
16 |
Correct |
56 ms |
21376 KB |
Output is correct |
17 |
Correct |
38 ms |
23380 KB |
Output is correct |
18 |
Correct |
39 ms |
23360 KB |
Output is correct |
19 |
Correct |
153 ms |
32012 KB |
Output is correct |
20 |
Correct |
124 ms |
32088 KB |
Output is correct |
21 |
Correct |
96 ms |
31724 KB |
Output is correct |
22 |
Correct |
118 ms |
31144 KB |
Output is correct |
23 |
Correct |
62 ms |
24312 KB |
Output is correct |
24 |
Correct |
57 ms |
24372 KB |
Output is correct |
25 |
Correct |
105 ms |
33876 KB |
Output is correct |
26 |
Correct |
117 ms |
31828 KB |
Output is correct |
27 |
Correct |
99 ms |
33996 KB |
Output is correct |
28 |
Correct |
97 ms |
33872 KB |
Output is correct |
29 |
Correct |
99 ms |
31788 KB |
Output is correct |
30 |
Correct |
62 ms |
24144 KB |
Output is correct |
31 |
Correct |
109 ms |
33872 KB |
Output is correct |
32 |
Correct |
95 ms |
33616 KB |
Output is correct |
33 |
Correct |
64 ms |
24116 KB |
Output is correct |
34 |
Correct |
103 ms |
33776 KB |
Output is correct |
35 |
Correct |
85 ms |
31572 KB |
Output is correct |
36 |
Correct |
66 ms |
24312 KB |
Output is correct |
37 |
Correct |
69 ms |
24144 KB |
Output is correct |
38 |
Correct |
95 ms |
31824 KB |
Output is correct |
39 |
Correct |
72 ms |
33872 KB |
Output is correct |
40 |
Correct |
76 ms |
29264 KB |
Output is correct |
41 |
Correct |
119 ms |
34132 KB |
Output is correct |
42 |
Correct |
37 ms |
33364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
21848 KB |
Output is correct |
2 |
Correct |
39 ms |
21904 KB |
Output is correct |
3 |
Correct |
38 ms |
19864 KB |
Output is correct |
4 |
Correct |
57 ms |
19740 KB |
Output is correct |
5 |
Correct |
38 ms |
23128 KB |
Output is correct |
6 |
Correct |
40 ms |
23164 KB |
Output is correct |
7 |
Correct |
38 ms |
23388 KB |
Output is correct |
8 |
Correct |
38 ms |
21328 KB |
Output is correct |
9 |
Correct |
41 ms |
21248 KB |
Output is correct |
10 |
Correct |
39 ms |
21340 KB |
Output is correct |
11 |
Correct |
61 ms |
23372 KB |
Output is correct |
12 |
Correct |
38 ms |
23272 KB |
Output is correct |
13 |
Correct |
39 ms |
23440 KB |
Output is correct |
14 |
Correct |
39 ms |
23328 KB |
Output is correct |
15 |
Correct |
61 ms |
23288 KB |
Output is correct |
16 |
Correct |
56 ms |
21376 KB |
Output is correct |
17 |
Correct |
38 ms |
23380 KB |
Output is correct |
18 |
Correct |
39 ms |
23360 KB |
Output is correct |
19 |
Correct |
38 ms |
23124 KB |
Output is correct |
20 |
Correct |
41 ms |
23124 KB |
Output is correct |
21 |
Correct |
37 ms |
23376 KB |
Output is correct |
22 |
Correct |
36 ms |
23232 KB |
Output is correct |
23 |
Correct |
37 ms |
23376 KB |
Output is correct |
24 |
Correct |
36 ms |
23132 KB |
Output is correct |
25 |
Correct |
37 ms |
23376 KB |
Output is correct |
26 |
Correct |
36 ms |
23132 KB |
Output is correct |
27 |
Correct |
38 ms |
23380 KB |
Output is correct |
28 |
Correct |
37 ms |
23004 KB |
Output is correct |
29 |
Correct |
37 ms |
23376 KB |
Output is correct |
30 |
Correct |
34 ms |
23144 KB |
Output is correct |
31 |
Correct |
41 ms |
23376 KB |
Output is correct |
32 |
Correct |
36 ms |
23308 KB |
Output is correct |
33 |
Correct |
38 ms |
23380 KB |
Output is correct |
34 |
Correct |
35 ms |
23128 KB |
Output is correct |
35 |
Correct |
38 ms |
23404 KB |
Output is correct |
36 |
Correct |
38 ms |
23380 KB |
Output is correct |
37 |
Correct |
37 ms |
23232 KB |
Output is correct |
38 |
Correct |
37 ms |
23380 KB |
Output is correct |
39 |
Correct |
38 ms |
23412 KB |
Output is correct |
40 |
Correct |
38 ms |
23380 KB |
Output is correct |
41 |
Correct |
37 ms |
23376 KB |
Output is correct |
42 |
Correct |
38 ms |
23376 KB |
Output is correct |
43 |
Correct |
37 ms |
23204 KB |
Output is correct |
44 |
Correct |
37 ms |
23384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
21848 KB |
Output is correct |
2 |
Correct |
39 ms |
21904 KB |
Output is correct |
3 |
Correct |
38 ms |
19864 KB |
Output is correct |
4 |
Correct |
57 ms |
19740 KB |
Output is correct |
5 |
Correct |
38 ms |
23128 KB |
Output is correct |
6 |
Correct |
40 ms |
23164 KB |
Output is correct |
7 |
Correct |
38 ms |
23388 KB |
Output is correct |
8 |
Correct |
38 ms |
21328 KB |
Output is correct |
9 |
Correct |
41 ms |
21248 KB |
Output is correct |
10 |
Correct |
39 ms |
21340 KB |
Output is correct |
11 |
Correct |
61 ms |
23372 KB |
Output is correct |
12 |
Correct |
38 ms |
23272 KB |
Output is correct |
13 |
Correct |
39 ms |
23440 KB |
Output is correct |
14 |
Correct |
39 ms |
23328 KB |
Output is correct |
15 |
Correct |
61 ms |
23288 KB |
Output is correct |
16 |
Correct |
56 ms |
21376 KB |
Output is correct |
17 |
Correct |
38 ms |
23380 KB |
Output is correct |
18 |
Correct |
39 ms |
23360 KB |
Output is correct |
19 |
Correct |
153 ms |
32012 KB |
Output is correct |
20 |
Correct |
124 ms |
32088 KB |
Output is correct |
21 |
Correct |
96 ms |
31724 KB |
Output is correct |
22 |
Correct |
118 ms |
31144 KB |
Output is correct |
23 |
Correct |
62 ms |
24312 KB |
Output is correct |
24 |
Correct |
57 ms |
24372 KB |
Output is correct |
25 |
Correct |
105 ms |
33876 KB |
Output is correct |
26 |
Correct |
117 ms |
31828 KB |
Output is correct |
27 |
Correct |
99 ms |
33996 KB |
Output is correct |
28 |
Correct |
97 ms |
33872 KB |
Output is correct |
29 |
Correct |
99 ms |
31788 KB |
Output is correct |
30 |
Correct |
62 ms |
24144 KB |
Output is correct |
31 |
Correct |
109 ms |
33872 KB |
Output is correct |
32 |
Correct |
95 ms |
33616 KB |
Output is correct |
33 |
Correct |
64 ms |
24116 KB |
Output is correct |
34 |
Correct |
103 ms |
33776 KB |
Output is correct |
35 |
Correct |
85 ms |
31572 KB |
Output is correct |
36 |
Correct |
66 ms |
24312 KB |
Output is correct |
37 |
Correct |
69 ms |
24144 KB |
Output is correct |
38 |
Correct |
95 ms |
31824 KB |
Output is correct |
39 |
Correct |
72 ms |
33872 KB |
Output is correct |
40 |
Correct |
76 ms |
29264 KB |
Output is correct |
41 |
Correct |
119 ms |
34132 KB |
Output is correct |
42 |
Correct |
37 ms |
33364 KB |
Output is correct |
43 |
Correct |
38 ms |
23124 KB |
Output is correct |
44 |
Correct |
41 ms |
23124 KB |
Output is correct |
45 |
Correct |
37 ms |
23376 KB |
Output is correct |
46 |
Correct |
36 ms |
23232 KB |
Output is correct |
47 |
Correct |
37 ms |
23376 KB |
Output is correct |
48 |
Correct |
36 ms |
23132 KB |
Output is correct |
49 |
Correct |
37 ms |
23376 KB |
Output is correct |
50 |
Correct |
36 ms |
23132 KB |
Output is correct |
51 |
Correct |
38 ms |
23380 KB |
Output is correct |
52 |
Correct |
37 ms |
23004 KB |
Output is correct |
53 |
Correct |
37 ms |
23376 KB |
Output is correct |
54 |
Correct |
34 ms |
23144 KB |
Output is correct |
55 |
Correct |
41 ms |
23376 KB |
Output is correct |
56 |
Correct |
36 ms |
23308 KB |
Output is correct |
57 |
Correct |
38 ms |
23380 KB |
Output is correct |
58 |
Correct |
35 ms |
23128 KB |
Output is correct |
59 |
Correct |
38 ms |
23404 KB |
Output is correct |
60 |
Correct |
38 ms |
23380 KB |
Output is correct |
61 |
Correct |
37 ms |
23232 KB |
Output is correct |
62 |
Correct |
37 ms |
23380 KB |
Output is correct |
63 |
Correct |
38 ms |
23412 KB |
Output is correct |
64 |
Correct |
38 ms |
23380 KB |
Output is correct |
65 |
Correct |
37 ms |
23376 KB |
Output is correct |
66 |
Correct |
38 ms |
23376 KB |
Output is correct |
67 |
Correct |
37 ms |
23204 KB |
Output is correct |
68 |
Correct |
37 ms |
23384 KB |
Output is correct |
69 |
Correct |
128 ms |
33312 KB |
Output is correct |
70 |
Correct |
111 ms |
33876 KB |
Output is correct |
71 |
Correct |
59 ms |
24144 KB |
Output is correct |
72 |
Correct |
61 ms |
24152 KB |
Output is correct |
73 |
Correct |
58 ms |
24152 KB |
Output is correct |
74 |
Correct |
83 ms |
33364 KB |
Output is correct |
75 |
Correct |
60 ms |
24148 KB |
Output is correct |
76 |
Correct |
89 ms |
33876 KB |
Output is correct |
77 |
Correct |
82 ms |
33624 KB |
Output is correct |
78 |
Correct |
57 ms |
24144 KB |
Output is correct |
79 |
Correct |
57 ms |
24144 KB |
Output is correct |
80 |
Correct |
78 ms |
33364 KB |
Output is correct |
81 |
Correct |
64 ms |
24260 KB |
Output is correct |
82 |
Correct |
94 ms |
33776 KB |
Output is correct |
83 |
Correct |
92 ms |
33616 KB |
Output is correct |
84 |
Correct |
61 ms |
24744 KB |
Output is correct |
85 |
Correct |
57 ms |
24144 KB |
Output is correct |
86 |
Correct |
103 ms |
33364 KB |
Output is correct |
87 |
Correct |
95 ms |
33812 KB |
Output is correct |
88 |
Correct |
66 ms |
24180 KB |
Output is correct |
89 |
Correct |
86 ms |
33456 KB |
Output is correct |
90 |
Correct |
98 ms |
33876 KB |
Output is correct |
91 |
Correct |
61 ms |
24144 KB |
Output is correct |
92 |
Correct |
83 ms |
33344 KB |
Output is correct |
93 |
Correct |
57 ms |
24192 KB |
Output is correct |
94 |
Correct |
61 ms |
24312 KB |
Output is correct |
95 |
Correct |
57 ms |
24240 KB |
Output is correct |
96 |
Correct |
96 ms |
31828 KB |
Output is correct |
97 |
Correct |
80 ms |
31924 KB |
Output is correct |
98 |
Correct |
83 ms |
28500 KB |
Output is correct |
99 |
Correct |
161 ms |
32080 KB |
Output is correct |
100 |
Correct |
38 ms |
31316 KB |
Output is correct |