#include <bits/stdc++.h>
using namespace std;
const int K = 26;
struct SegTree
{
int l, r, mid;
SegTree *lc, *rc;
int val;
SegTree(const vector<int> &a, int l_, int r_) : l(l_), r(r_)
{
mid = (l + r) / 2;
if (l == r - 1)
{
val = a[l];
return;
}
lc = new SegTree(a, l, mid);
rc = new SegTree(a, mid, r);
pull();
}
void pull()
{
val = (rc->val + ((r - mid) % 2 == 0 ? 1 : -1) * lc->val + K) % K;
}
void update(int i, int u)
{
if (l == r - 1)
{
val = u;
return;
}
if (i < mid)
{
lc->update(i, u);
}
else
{
rc->update(i, u);
}
pull();
}
};
int main()
{
cin.tie(0)->sync_with_stdio(0);
int n, q;
cin >> n >> q;
string a, b;
cin >> a >> b;
vector<int> c(n);
for (int i = 0; i < n; i++)
{
c[i] = (b[i] - a[i] + K) % K;
}
SegTree st(c, 0, n);
cout << (st.val == 0 ? "da" : "ne") << '\n';
while (q--)
{
int j;
char x;
cin >> j >> x;
j--;
a[j] = x;
st.update(j, (b[j] - a[j] + K) % K);
cout << (st.val == 0 ? "da" : "ne") << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
460 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
460 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
71 ms |
101904 KB |
Output is correct |
32 |
Correct |
71 ms |
102020 KB |
Output is correct |
33 |
Correct |
80 ms |
101956 KB |
Output is correct |
34 |
Correct |
72 ms |
102032 KB |
Output is correct |
35 |
Correct |
72 ms |
102136 KB |
Output is correct |
36 |
Correct |
69 ms |
101964 KB |
Output is correct |
37 |
Correct |
70 ms |
102124 KB |
Output is correct |
38 |
Correct |
71 ms |
102028 KB |
Output is correct |
39 |
Correct |
70 ms |
102116 KB |
Output is correct |
40 |
Correct |
70 ms |
101812 KB |
Output is correct |
41 |
Correct |
73 ms |
101772 KB |
Output is correct |
42 |
Correct |
70 ms |
101244 KB |
Output is correct |
43 |
Correct |
70 ms |
101256 KB |
Output is correct |
44 |
Correct |
71 ms |
101352 KB |
Output is correct |
45 |
Correct |
70 ms |
101392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
11 ms |
1112 KB |
Output is correct |
17 |
Correct |
11 ms |
1116 KB |
Output is correct |
18 |
Correct |
11 ms |
1116 KB |
Output is correct |
19 |
Correct |
10 ms |
1116 KB |
Output is correct |
20 |
Correct |
11 ms |
1116 KB |
Output is correct |
21 |
Correct |
10 ms |
1112 KB |
Output is correct |
22 |
Correct |
11 ms |
1116 KB |
Output is correct |
23 |
Correct |
10 ms |
1116 KB |
Output is correct |
24 |
Correct |
11 ms |
1116 KB |
Output is correct |
25 |
Correct |
11 ms |
1368 KB |
Output is correct |
26 |
Correct |
11 ms |
972 KB |
Output is correct |
27 |
Correct |
10 ms |
1100 KB |
Output is correct |
28 |
Correct |
11 ms |
1112 KB |
Output is correct |
29 |
Correct |
11 ms |
1116 KB |
Output is correct |
30 |
Correct |
11 ms |
980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
460 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
11 ms |
1112 KB |
Output is correct |
32 |
Correct |
11 ms |
1116 KB |
Output is correct |
33 |
Correct |
11 ms |
1116 KB |
Output is correct |
34 |
Correct |
10 ms |
1116 KB |
Output is correct |
35 |
Correct |
11 ms |
1116 KB |
Output is correct |
36 |
Correct |
10 ms |
1112 KB |
Output is correct |
37 |
Correct |
11 ms |
1116 KB |
Output is correct |
38 |
Correct |
10 ms |
1116 KB |
Output is correct |
39 |
Correct |
11 ms |
1116 KB |
Output is correct |
40 |
Correct |
11 ms |
1368 KB |
Output is correct |
41 |
Correct |
11 ms |
972 KB |
Output is correct |
42 |
Correct |
10 ms |
1100 KB |
Output is correct |
43 |
Correct |
11 ms |
1112 KB |
Output is correct |
44 |
Correct |
11 ms |
1116 KB |
Output is correct |
45 |
Correct |
11 ms |
980 KB |
Output is correct |
46 |
Correct |
25 ms |
1372 KB |
Output is correct |
47 |
Correct |
21 ms |
1368 KB |
Output is correct |
48 |
Correct |
22 ms |
1292 KB |
Output is correct |
49 |
Correct |
25 ms |
1232 KB |
Output is correct |
50 |
Correct |
21 ms |
1372 KB |
Output is correct |
51 |
Correct |
21 ms |
1292 KB |
Output is correct |
52 |
Correct |
22 ms |
1372 KB |
Output is correct |
53 |
Correct |
21 ms |
1116 KB |
Output is correct |
54 |
Correct |
22 ms |
1368 KB |
Output is correct |
55 |
Correct |
21 ms |
1116 KB |
Output is correct |
56 |
Correct |
21 ms |
1260 KB |
Output is correct |
57 |
Correct |
22 ms |
1276 KB |
Output is correct |
58 |
Correct |
22 ms |
1112 KB |
Output is correct |
59 |
Correct |
21 ms |
1372 KB |
Output is correct |
60 |
Correct |
22 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
460 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
71 ms |
101904 KB |
Output is correct |
32 |
Correct |
71 ms |
102020 KB |
Output is correct |
33 |
Correct |
80 ms |
101956 KB |
Output is correct |
34 |
Correct |
72 ms |
102032 KB |
Output is correct |
35 |
Correct |
72 ms |
102136 KB |
Output is correct |
36 |
Correct |
69 ms |
101964 KB |
Output is correct |
37 |
Correct |
70 ms |
102124 KB |
Output is correct |
38 |
Correct |
71 ms |
102028 KB |
Output is correct |
39 |
Correct |
70 ms |
102116 KB |
Output is correct |
40 |
Correct |
70 ms |
101812 KB |
Output is correct |
41 |
Correct |
73 ms |
101772 KB |
Output is correct |
42 |
Correct |
70 ms |
101244 KB |
Output is correct |
43 |
Correct |
70 ms |
101256 KB |
Output is correct |
44 |
Correct |
71 ms |
101352 KB |
Output is correct |
45 |
Correct |
70 ms |
101392 KB |
Output is correct |
46 |
Correct |
11 ms |
1112 KB |
Output is correct |
47 |
Correct |
11 ms |
1116 KB |
Output is correct |
48 |
Correct |
11 ms |
1116 KB |
Output is correct |
49 |
Correct |
10 ms |
1116 KB |
Output is correct |
50 |
Correct |
11 ms |
1116 KB |
Output is correct |
51 |
Correct |
10 ms |
1112 KB |
Output is correct |
52 |
Correct |
11 ms |
1116 KB |
Output is correct |
53 |
Correct |
10 ms |
1116 KB |
Output is correct |
54 |
Correct |
11 ms |
1116 KB |
Output is correct |
55 |
Correct |
11 ms |
1368 KB |
Output is correct |
56 |
Correct |
11 ms |
972 KB |
Output is correct |
57 |
Correct |
10 ms |
1100 KB |
Output is correct |
58 |
Correct |
11 ms |
1112 KB |
Output is correct |
59 |
Correct |
11 ms |
1116 KB |
Output is correct |
60 |
Correct |
11 ms |
980 KB |
Output is correct |
61 |
Correct |
25 ms |
1372 KB |
Output is correct |
62 |
Correct |
21 ms |
1368 KB |
Output is correct |
63 |
Correct |
22 ms |
1292 KB |
Output is correct |
64 |
Correct |
25 ms |
1232 KB |
Output is correct |
65 |
Correct |
21 ms |
1372 KB |
Output is correct |
66 |
Correct |
21 ms |
1292 KB |
Output is correct |
67 |
Correct |
22 ms |
1372 KB |
Output is correct |
68 |
Correct |
21 ms |
1116 KB |
Output is correct |
69 |
Correct |
22 ms |
1368 KB |
Output is correct |
70 |
Correct |
21 ms |
1116 KB |
Output is correct |
71 |
Correct |
21 ms |
1260 KB |
Output is correct |
72 |
Correct |
22 ms |
1276 KB |
Output is correct |
73 |
Correct |
22 ms |
1112 KB |
Output is correct |
74 |
Correct |
21 ms |
1372 KB |
Output is correct |
75 |
Correct |
22 ms |
1116 KB |
Output is correct |
76 |
Execution timed out |
1025 ms |
107864 KB |
Time limit exceeded |
77 |
Halted |
0 ms |
0 KB |
- |