#include <bits/stdc++.h>
using namespace std;
struct segtree{
vector<char> curequals;
vector<char> targequals;
vector<bool> equals;
string cur;
string targ;
int size;
segtree(int _size, string _cur, string _targ): cur(_cur), targ(_targ), size(_size){
curequals.resize(4*size+5);
targequals.resize(4*size+5);
equals.resize(4*size+5);
build(0, size-1, 0);
}
void build(int left, int right, int pos){
if(left!=right){
int mid = (left+right)/2;
build(left, mid, 2*pos+1);
build(mid+1, right, 2*pos+2);
if(targequals[2*pos+1]==targequals[2*pos+2]){
targequals[pos]=targequals[2*pos+1];
}
else{
targequals[pos]='0';
}
if(curequals[2*pos+1]==curequals[2*pos+2]){
curequals[pos]=curequals[2*pos+1];
}
else{
curequals[pos]='0';
}
equals[pos]=(equals[2*pos+1] && equals[2*pos+2]);
}
else{
targequals[pos] = targ[left];
curequals[pos] = cur[left];
equals[pos] = (targequals[pos]==curequals[pos]);
}
}
void update(char c, int left, int right, int start, int end, int pos){
if(start==left && end==right){
curequals[pos] = c;
equals[pos] = (targequals[pos]!='0' && curequals[pos]==targequals[pos]);
}
else{
if(curequals[pos]!='0'){
curequals[2*pos+1] = curequals[pos];
equals[2*pos+1] = (targequals[2*pos+1]==curequals[2*pos+1]);
curequals[2*pos+2] = curequals[pos];
equals[2*pos+2] = (targequals[2*pos+2]==curequals[2*pos+2]);
curequals[pos] = '0';
}
int mid = (left+right)/2;
if(start>mid){
update(c, mid+1, right, start, end, 2*pos+2);
}
else if(end<=mid){
update(c, left, mid, start, end, 2*pos+1);
}
else{
update(c, left, mid, start, mid, 2*pos+1);
update(c, mid+1, right, mid+1, end, 2*pos+2);
}
equals[pos] = (equals[2*pos+2] && equals[2*pos+1]);
}
}
};
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
string a, b, c;
cin >> a >> b >> c;
int q;
cin >> q;
string init;
cin >> init;
segtree root(n, init, a);
if(root.equals[0]){
cout << "Yes\n";
}
else{
cout << "No\n";
}
for(int i=0; i<q; i++){
int d, e;
char f;
cin >> d >> e >> f;
d--;
e--;
root.update(f, 0, n-1, d, e, 0);
if(root.equals[0]){
cout << "Yes\n";
}
else{
cout << "No\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
844 KB |
Output is correct |
2 |
Correct |
66 ms |
896 KB |
Output is correct |
3 |
Correct |
68 ms |
804 KB |
Output is correct |
4 |
Correct |
58 ms |
836 KB |
Output is correct |
5 |
Correct |
57 ms |
832 KB |
Output is correct |
6 |
Correct |
55 ms |
848 KB |
Output is correct |
7 |
Correct |
56 ms |
872 KB |
Output is correct |
8 |
Correct |
58 ms |
900 KB |
Output is correct |
9 |
Correct |
63 ms |
868 KB |
Output is correct |
10 |
Correct |
67 ms |
844 KB |
Output is correct |
11 |
Correct |
58 ms |
892 KB |
Output is correct |
12 |
Correct |
62 ms |
840 KB |
Output is correct |
13 |
Correct |
62 ms |
868 KB |
Output is correct |
14 |
Correct |
60 ms |
804 KB |
Output is correct |
15 |
Correct |
61 ms |
824 KB |
Output is correct |
16 |
Correct |
60 ms |
800 KB |
Output is correct |
17 |
Correct |
59 ms |
836 KB |
Output is correct |
18 |
Correct |
66 ms |
936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
844 KB |
Output is correct |
2 |
Correct |
66 ms |
896 KB |
Output is correct |
3 |
Correct |
68 ms |
804 KB |
Output is correct |
4 |
Correct |
58 ms |
836 KB |
Output is correct |
5 |
Correct |
57 ms |
832 KB |
Output is correct |
6 |
Correct |
55 ms |
848 KB |
Output is correct |
7 |
Correct |
56 ms |
872 KB |
Output is correct |
8 |
Correct |
58 ms |
900 KB |
Output is correct |
9 |
Correct |
63 ms |
868 KB |
Output is correct |
10 |
Correct |
67 ms |
844 KB |
Output is correct |
11 |
Correct |
58 ms |
892 KB |
Output is correct |
12 |
Correct |
62 ms |
840 KB |
Output is correct |
13 |
Correct |
62 ms |
868 KB |
Output is correct |
14 |
Correct |
60 ms |
804 KB |
Output is correct |
15 |
Correct |
61 ms |
824 KB |
Output is correct |
16 |
Correct |
60 ms |
800 KB |
Output is correct |
17 |
Correct |
59 ms |
836 KB |
Output is correct |
18 |
Correct |
66 ms |
936 KB |
Output is correct |
19 |
Correct |
176 ms |
6548 KB |
Output is correct |
20 |
Correct |
192 ms |
7340 KB |
Output is correct |
21 |
Correct |
110 ms |
7120 KB |
Output is correct |
22 |
Correct |
109 ms |
6668 KB |
Output is correct |
23 |
Correct |
87 ms |
3372 KB |
Output is correct |
24 |
Correct |
88 ms |
3404 KB |
Output is correct |
25 |
Correct |
118 ms |
7412 KB |
Output is correct |
26 |
Correct |
121 ms |
7472 KB |
Output is correct |
27 |
Correct |
147 ms |
7596 KB |
Output is correct |
28 |
Correct |
150 ms |
7468 KB |
Output is correct |
29 |
Correct |
145 ms |
7412 KB |
Output is correct |
30 |
Correct |
99 ms |
3468 KB |
Output is correct |
31 |
Correct |
152 ms |
7448 KB |
Output is correct |
32 |
Correct |
132 ms |
7048 KB |
Output is correct |
33 |
Correct |
93 ms |
3408 KB |
Output is correct |
34 |
Correct |
166 ms |
7428 KB |
Output is correct |
35 |
Correct |
103 ms |
6276 KB |
Output is correct |
36 |
Correct |
89 ms |
3308 KB |
Output is correct |
37 |
Correct |
86 ms |
3364 KB |
Output is correct |
38 |
Correct |
161 ms |
7316 KB |
Output is correct |
39 |
Correct |
94 ms |
7440 KB |
Output is correct |
40 |
Correct |
112 ms |
6264 KB |
Output is correct |
41 |
Correct |
197 ms |
7620 KB |
Output is correct |
42 |
Correct |
42 ms |
6924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
844 KB |
Output is correct |
2 |
Correct |
66 ms |
896 KB |
Output is correct |
3 |
Correct |
68 ms |
804 KB |
Output is correct |
4 |
Correct |
58 ms |
836 KB |
Output is correct |
5 |
Correct |
57 ms |
832 KB |
Output is correct |
6 |
Correct |
55 ms |
848 KB |
Output is correct |
7 |
Correct |
56 ms |
872 KB |
Output is correct |
8 |
Correct |
58 ms |
900 KB |
Output is correct |
9 |
Correct |
63 ms |
868 KB |
Output is correct |
10 |
Correct |
67 ms |
844 KB |
Output is correct |
11 |
Correct |
58 ms |
892 KB |
Output is correct |
12 |
Correct |
62 ms |
840 KB |
Output is correct |
13 |
Correct |
62 ms |
868 KB |
Output is correct |
14 |
Correct |
60 ms |
804 KB |
Output is correct |
15 |
Correct |
61 ms |
824 KB |
Output is correct |
16 |
Correct |
60 ms |
800 KB |
Output is correct |
17 |
Correct |
59 ms |
836 KB |
Output is correct |
18 |
Correct |
66 ms |
936 KB |
Output is correct |
19 |
Correct |
63 ms |
756 KB |
Output is correct |
20 |
Correct |
71 ms |
888 KB |
Output is correct |
21 |
Incorrect |
59 ms |
824 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
844 KB |
Output is correct |
2 |
Correct |
66 ms |
896 KB |
Output is correct |
3 |
Correct |
68 ms |
804 KB |
Output is correct |
4 |
Correct |
58 ms |
836 KB |
Output is correct |
5 |
Correct |
57 ms |
832 KB |
Output is correct |
6 |
Correct |
55 ms |
848 KB |
Output is correct |
7 |
Correct |
56 ms |
872 KB |
Output is correct |
8 |
Correct |
58 ms |
900 KB |
Output is correct |
9 |
Correct |
63 ms |
868 KB |
Output is correct |
10 |
Correct |
67 ms |
844 KB |
Output is correct |
11 |
Correct |
58 ms |
892 KB |
Output is correct |
12 |
Correct |
62 ms |
840 KB |
Output is correct |
13 |
Correct |
62 ms |
868 KB |
Output is correct |
14 |
Correct |
60 ms |
804 KB |
Output is correct |
15 |
Correct |
61 ms |
824 KB |
Output is correct |
16 |
Correct |
60 ms |
800 KB |
Output is correct |
17 |
Correct |
59 ms |
836 KB |
Output is correct |
18 |
Correct |
66 ms |
936 KB |
Output is correct |
19 |
Correct |
176 ms |
6548 KB |
Output is correct |
20 |
Correct |
192 ms |
7340 KB |
Output is correct |
21 |
Correct |
110 ms |
7120 KB |
Output is correct |
22 |
Correct |
109 ms |
6668 KB |
Output is correct |
23 |
Correct |
87 ms |
3372 KB |
Output is correct |
24 |
Correct |
88 ms |
3404 KB |
Output is correct |
25 |
Correct |
118 ms |
7412 KB |
Output is correct |
26 |
Correct |
121 ms |
7472 KB |
Output is correct |
27 |
Correct |
147 ms |
7596 KB |
Output is correct |
28 |
Correct |
150 ms |
7468 KB |
Output is correct |
29 |
Correct |
145 ms |
7412 KB |
Output is correct |
30 |
Correct |
99 ms |
3468 KB |
Output is correct |
31 |
Correct |
152 ms |
7448 KB |
Output is correct |
32 |
Correct |
132 ms |
7048 KB |
Output is correct |
33 |
Correct |
93 ms |
3408 KB |
Output is correct |
34 |
Correct |
166 ms |
7428 KB |
Output is correct |
35 |
Correct |
103 ms |
6276 KB |
Output is correct |
36 |
Correct |
89 ms |
3308 KB |
Output is correct |
37 |
Correct |
86 ms |
3364 KB |
Output is correct |
38 |
Correct |
161 ms |
7316 KB |
Output is correct |
39 |
Correct |
94 ms |
7440 KB |
Output is correct |
40 |
Correct |
112 ms |
6264 KB |
Output is correct |
41 |
Correct |
197 ms |
7620 KB |
Output is correct |
42 |
Correct |
42 ms |
6924 KB |
Output is correct |
43 |
Correct |
63 ms |
756 KB |
Output is correct |
44 |
Correct |
71 ms |
888 KB |
Output is correct |
45 |
Incorrect |
59 ms |
824 KB |
Output isn't correct |
46 |
Halted |
0 ms |
0 KB |
- |