#include <bits/stdc++.h>
using namespace std;
int N, Q;
string s, t;
struct segtree{
int st[1000005 << 1];
void upd(int p, int v){
for(p += 1000005, st[p] = v, p >>= 1; p > 0; p >>= 1) st[p] = st[p << 1] + st[p << 1|1];
}
int que(int l, int r){
int res = 0;
for(l += 1000005, r += 1000005 + 1; l < r; l >>= 1, r >>= 1){
if(l & 1) res += st[l++];
if(r & 1) res += st[--r];
}
return res;
}
} S;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> N >> Q >> s >> t;
for(int i = N - 1; i >= 0; i--){
int x = ((int) t[i] - (int) s[i] + 26) % 26;
if((N - 1 - i) & 1) S.upd(i, -x);
else S.upd(i, x);
}
if(S.que(0, N - 1) % 26 == 0) cout << "da\n";
else cout << "ne\n";
for(int i = 0; i < Q; i++){
int p; char c; cin >> p >> c; p--;
int x = ((int) t[p] - (int) c + 26) % 26;
if((N - p - 1) & 1) S.upd(p, -x);
else S.upd(p, x);
s[p] = c;
if(S.que(0, N - 1) % 26 == 0) cout << "da\n";
else cout << "ne\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
4440 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
1 ms |
4440 KB |
Output is correct |
8 |
Correct |
1 ms |
4440 KB |
Output is correct |
9 |
Correct |
1 ms |
4440 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4440 KB |
Output is correct |
13 |
Correct |
1 ms |
4440 KB |
Output is correct |
14 |
Correct |
1 ms |
4440 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
4440 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
1 ms |
4440 KB |
Output is correct |
8 |
Correct |
1 ms |
4440 KB |
Output is correct |
9 |
Correct |
1 ms |
4440 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4440 KB |
Output is correct |
13 |
Correct |
1 ms |
4440 KB |
Output is correct |
14 |
Correct |
1 ms |
4440 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4440 KB |
Output is correct |
17 |
Correct |
1 ms |
4696 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
21 |
Correct |
1 ms |
4440 KB |
Output is correct |
22 |
Correct |
1 ms |
4444 KB |
Output is correct |
23 |
Correct |
1 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4440 KB |
Output is correct |
25 |
Correct |
1 ms |
4440 KB |
Output is correct |
26 |
Correct |
1 ms |
4440 KB |
Output is correct |
27 |
Correct |
1 ms |
4440 KB |
Output is correct |
28 |
Correct |
1 ms |
4440 KB |
Output is correct |
29 |
Correct |
1 ms |
4440 KB |
Output is correct |
30 |
Correct |
1 ms |
4440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
4440 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
1 ms |
4440 KB |
Output is correct |
8 |
Correct |
1 ms |
4440 KB |
Output is correct |
9 |
Correct |
1 ms |
4440 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4440 KB |
Output is correct |
13 |
Correct |
1 ms |
4440 KB |
Output is correct |
14 |
Correct |
1 ms |
4440 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4440 KB |
Output is correct |
17 |
Correct |
1 ms |
4696 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
21 |
Correct |
1 ms |
4440 KB |
Output is correct |
22 |
Correct |
1 ms |
4444 KB |
Output is correct |
23 |
Correct |
1 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4440 KB |
Output is correct |
25 |
Correct |
1 ms |
4440 KB |
Output is correct |
26 |
Correct |
1 ms |
4440 KB |
Output is correct |
27 |
Correct |
1 ms |
4440 KB |
Output is correct |
28 |
Correct |
1 ms |
4440 KB |
Output is correct |
29 |
Correct |
1 ms |
4440 KB |
Output is correct |
30 |
Correct |
1 ms |
4440 KB |
Output is correct |
31 |
Correct |
38 ms |
12160 KB |
Output is correct |
32 |
Correct |
42 ms |
12508 KB |
Output is correct |
33 |
Correct |
38 ms |
12180 KB |
Output is correct |
34 |
Correct |
38 ms |
12176 KB |
Output is correct |
35 |
Correct |
38 ms |
12224 KB |
Output is correct |
36 |
Correct |
41 ms |
12928 KB |
Output is correct |
37 |
Correct |
39 ms |
12520 KB |
Output is correct |
38 |
Correct |
40 ms |
12208 KB |
Output is correct |
39 |
Correct |
40 ms |
13036 KB |
Output is correct |
40 |
Correct |
39 ms |
12516 KB |
Output is correct |
41 |
Correct |
38 ms |
12176 KB |
Output is correct |
42 |
Correct |
38 ms |
12160 KB |
Output is correct |
43 |
Correct |
38 ms |
12468 KB |
Output is correct |
44 |
Correct |
38 ms |
12128 KB |
Output is correct |
45 |
Correct |
39 ms |
12172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
4440 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
1 ms |
4440 KB |
Output is correct |
8 |
Correct |
1 ms |
4440 KB |
Output is correct |
9 |
Correct |
1 ms |
4440 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4440 KB |
Output is correct |
13 |
Correct |
1 ms |
4440 KB |
Output is correct |
14 |
Correct |
1 ms |
4440 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
12 ms |
5208 KB |
Output is correct |
17 |
Correct |
12 ms |
5208 KB |
Output is correct |
18 |
Correct |
12 ms |
5208 KB |
Output is correct |
19 |
Correct |
12 ms |
5208 KB |
Output is correct |
20 |
Correct |
12 ms |
5212 KB |
Output is correct |
21 |
Correct |
13 ms |
5208 KB |
Output is correct |
22 |
Correct |
12 ms |
5212 KB |
Output is correct |
23 |
Correct |
12 ms |
5212 KB |
Output is correct |
24 |
Correct |
12 ms |
5208 KB |
Output is correct |
25 |
Correct |
12 ms |
5212 KB |
Output is correct |
26 |
Correct |
12 ms |
5208 KB |
Output is correct |
27 |
Correct |
12 ms |
5208 KB |
Output is correct |
28 |
Correct |
12 ms |
5208 KB |
Output is correct |
29 |
Correct |
12 ms |
5208 KB |
Output is correct |
30 |
Correct |
12 ms |
5208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
4440 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
1 ms |
4440 KB |
Output is correct |
8 |
Correct |
1 ms |
4440 KB |
Output is correct |
9 |
Correct |
1 ms |
4440 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4440 KB |
Output is correct |
13 |
Correct |
1 ms |
4440 KB |
Output is correct |
14 |
Correct |
1 ms |
4440 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4440 KB |
Output is correct |
17 |
Correct |
1 ms |
4696 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
21 |
Correct |
1 ms |
4440 KB |
Output is correct |
22 |
Correct |
1 ms |
4444 KB |
Output is correct |
23 |
Correct |
1 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4440 KB |
Output is correct |
25 |
Correct |
1 ms |
4440 KB |
Output is correct |
26 |
Correct |
1 ms |
4440 KB |
Output is correct |
27 |
Correct |
1 ms |
4440 KB |
Output is correct |
28 |
Correct |
1 ms |
4440 KB |
Output is correct |
29 |
Correct |
1 ms |
4440 KB |
Output is correct |
30 |
Correct |
1 ms |
4440 KB |
Output is correct |
31 |
Correct |
12 ms |
5208 KB |
Output is correct |
32 |
Correct |
12 ms |
5208 KB |
Output is correct |
33 |
Correct |
12 ms |
5208 KB |
Output is correct |
34 |
Correct |
12 ms |
5208 KB |
Output is correct |
35 |
Correct |
12 ms |
5212 KB |
Output is correct |
36 |
Correct |
13 ms |
5208 KB |
Output is correct |
37 |
Correct |
12 ms |
5212 KB |
Output is correct |
38 |
Correct |
12 ms |
5212 KB |
Output is correct |
39 |
Correct |
12 ms |
5208 KB |
Output is correct |
40 |
Correct |
12 ms |
5212 KB |
Output is correct |
41 |
Correct |
12 ms |
5208 KB |
Output is correct |
42 |
Correct |
12 ms |
5208 KB |
Output is correct |
43 |
Correct |
12 ms |
5208 KB |
Output is correct |
44 |
Correct |
12 ms |
5208 KB |
Output is correct |
45 |
Correct |
12 ms |
5208 KB |
Output is correct |
46 |
Correct |
14 ms |
5476 KB |
Output is correct |
47 |
Correct |
15 ms |
5464 KB |
Output is correct |
48 |
Correct |
15 ms |
5464 KB |
Output is correct |
49 |
Correct |
14 ms |
5464 KB |
Output is correct |
50 |
Correct |
14 ms |
5464 KB |
Output is correct |
51 |
Correct |
14 ms |
5464 KB |
Output is correct |
52 |
Correct |
14 ms |
5208 KB |
Output is correct |
53 |
Correct |
14 ms |
5464 KB |
Output is correct |
54 |
Correct |
14 ms |
5464 KB |
Output is correct |
55 |
Correct |
14 ms |
5456 KB |
Output is correct |
56 |
Correct |
15 ms |
5464 KB |
Output is correct |
57 |
Correct |
14 ms |
5456 KB |
Output is correct |
58 |
Correct |
15 ms |
5356 KB |
Output is correct |
59 |
Correct |
17 ms |
5668 KB |
Output is correct |
60 |
Correct |
14 ms |
5464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
4440 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
1 ms |
4440 KB |
Output is correct |
8 |
Correct |
1 ms |
4440 KB |
Output is correct |
9 |
Correct |
1 ms |
4440 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4440 KB |
Output is correct |
13 |
Correct |
1 ms |
4440 KB |
Output is correct |
14 |
Correct |
1 ms |
4440 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4440 KB |
Output is correct |
17 |
Correct |
1 ms |
4696 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
21 |
Correct |
1 ms |
4440 KB |
Output is correct |
22 |
Correct |
1 ms |
4444 KB |
Output is correct |
23 |
Correct |
1 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4440 KB |
Output is correct |
25 |
Correct |
1 ms |
4440 KB |
Output is correct |
26 |
Correct |
1 ms |
4440 KB |
Output is correct |
27 |
Correct |
1 ms |
4440 KB |
Output is correct |
28 |
Correct |
1 ms |
4440 KB |
Output is correct |
29 |
Correct |
1 ms |
4440 KB |
Output is correct |
30 |
Correct |
1 ms |
4440 KB |
Output is correct |
31 |
Correct |
38 ms |
12160 KB |
Output is correct |
32 |
Correct |
42 ms |
12508 KB |
Output is correct |
33 |
Correct |
38 ms |
12180 KB |
Output is correct |
34 |
Correct |
38 ms |
12176 KB |
Output is correct |
35 |
Correct |
38 ms |
12224 KB |
Output is correct |
36 |
Correct |
41 ms |
12928 KB |
Output is correct |
37 |
Correct |
39 ms |
12520 KB |
Output is correct |
38 |
Correct |
40 ms |
12208 KB |
Output is correct |
39 |
Correct |
40 ms |
13036 KB |
Output is correct |
40 |
Correct |
39 ms |
12516 KB |
Output is correct |
41 |
Correct |
38 ms |
12176 KB |
Output is correct |
42 |
Correct |
38 ms |
12160 KB |
Output is correct |
43 |
Correct |
38 ms |
12468 KB |
Output is correct |
44 |
Correct |
38 ms |
12128 KB |
Output is correct |
45 |
Correct |
39 ms |
12172 KB |
Output is correct |
46 |
Correct |
12 ms |
5208 KB |
Output is correct |
47 |
Correct |
12 ms |
5208 KB |
Output is correct |
48 |
Correct |
12 ms |
5208 KB |
Output is correct |
49 |
Correct |
12 ms |
5208 KB |
Output is correct |
50 |
Correct |
12 ms |
5212 KB |
Output is correct |
51 |
Correct |
13 ms |
5208 KB |
Output is correct |
52 |
Correct |
12 ms |
5212 KB |
Output is correct |
53 |
Correct |
12 ms |
5212 KB |
Output is correct |
54 |
Correct |
12 ms |
5208 KB |
Output is correct |
55 |
Correct |
12 ms |
5212 KB |
Output is correct |
56 |
Correct |
12 ms |
5208 KB |
Output is correct |
57 |
Correct |
12 ms |
5208 KB |
Output is correct |
58 |
Correct |
12 ms |
5208 KB |
Output is correct |
59 |
Correct |
12 ms |
5208 KB |
Output is correct |
60 |
Correct |
12 ms |
5208 KB |
Output is correct |
61 |
Correct |
14 ms |
5476 KB |
Output is correct |
62 |
Correct |
15 ms |
5464 KB |
Output is correct |
63 |
Correct |
15 ms |
5464 KB |
Output is correct |
64 |
Correct |
14 ms |
5464 KB |
Output is correct |
65 |
Correct |
14 ms |
5464 KB |
Output is correct |
66 |
Correct |
14 ms |
5464 KB |
Output is correct |
67 |
Correct |
14 ms |
5208 KB |
Output is correct |
68 |
Correct |
14 ms |
5464 KB |
Output is correct |
69 |
Correct |
14 ms |
5464 KB |
Output is correct |
70 |
Correct |
14 ms |
5456 KB |
Output is correct |
71 |
Correct |
15 ms |
5464 KB |
Output is correct |
72 |
Correct |
14 ms |
5456 KB |
Output is correct |
73 |
Correct |
15 ms |
5356 KB |
Output is correct |
74 |
Correct |
17 ms |
5668 KB |
Output is correct |
75 |
Correct |
14 ms |
5464 KB |
Output is correct |
76 |
Correct |
242 ms |
23936 KB |
Output is correct |
77 |
Correct |
226 ms |
24408 KB |
Output is correct |
78 |
Correct |
215 ms |
24032 KB |
Output is correct |
79 |
Correct |
220 ms |
23928 KB |
Output is correct |
80 |
Correct |
234 ms |
24016 KB |
Output is correct |
81 |
Correct |
217 ms |
23936 KB |
Output is correct |
82 |
Correct |
215 ms |
23936 KB |
Output is correct |
83 |
Correct |
225 ms |
24260 KB |
Output is correct |
84 |
Correct |
214 ms |
23952 KB |
Output is correct |
85 |
Correct |
218 ms |
23860 KB |
Output is correct |
86 |
Correct |
235 ms |
24396 KB |
Output is correct |
87 |
Correct |
227 ms |
24288 KB |
Output is correct |
88 |
Correct |
208 ms |
24404 KB |
Output is correct |
89 |
Correct |
231 ms |
24192 KB |
Output is correct |
90 |
Correct |
210 ms |
24288 KB |
Output is correct |