// Author : FatihCihan
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
void solve(){
int n,q;
cin >> n >> q;
string s1 , s2;
cin >> s1 >> s2;
int arr[n] , sum[2] = {0,0};
for(int i = 0;i<n;i++){
arr[i] = s2[i] - s1[i];
if(arr[i] < 0)arr[i] += 26;
if(i < (n-1))sum[i & 1] += arr[i];
}
// cout << "arr : ";for(int i = 0;i<n;i++)cout << arr[i] << " ";cout << endl;
auto get = [&]{
int value = ((sum[n&1] - sum[(n&1)^1]) % 26 + 26) % 26;
if(value == arr[n-1])return "da";
else return "ne";
};
cout << get() << endl;
while(q--){
int pos;
char ch;
cin >> pos >> ch;
pos--;
if(pos < (n-1))sum[pos&1] -= arr[pos];
s1[pos] = ch;
arr[pos] = s2[pos] - s1[pos];
if(arr[pos] < 0)arr[pos] += 26;
if(pos < (n-1))sum[pos&1] += arr[pos];
cout << get() << endl;
}
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int testcase = 1;//cin >> testcase;
while(testcase--)solve();
cerr << 1000.0 * clock() / CLOCKS_PER_SEC << " ms" << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
10 ms |
6272 KB |
Output is correct |
32 |
Correct |
15 ms |
7808 KB |
Output is correct |
33 |
Correct |
10 ms |
6292 KB |
Output is correct |
34 |
Correct |
10 ms |
6288 KB |
Output is correct |
35 |
Correct |
9 ms |
6312 KB |
Output is correct |
36 |
Correct |
9 ms |
6632 KB |
Output is correct |
37 |
Correct |
9 ms |
6632 KB |
Output is correct |
38 |
Correct |
10 ms |
6300 KB |
Output is correct |
39 |
Correct |
9 ms |
6636 KB |
Output is correct |
40 |
Correct |
15 ms |
8116 KB |
Output is correct |
41 |
Correct |
13 ms |
7504 KB |
Output is correct |
42 |
Correct |
11 ms |
6272 KB |
Output is correct |
43 |
Correct |
12 ms |
7916 KB |
Output is correct |
44 |
Correct |
14 ms |
7564 KB |
Output is correct |
45 |
Correct |
13 ms |
7484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
148 ms |
508 KB |
Output is correct |
17 |
Correct |
143 ms |
532 KB |
Output is correct |
18 |
Correct |
150 ms |
584 KB |
Output is correct |
19 |
Correct |
143 ms |
580 KB |
Output is correct |
20 |
Correct |
145 ms |
584 KB |
Output is correct |
21 |
Correct |
147 ms |
1104 KB |
Output is correct |
22 |
Correct |
155 ms |
584 KB |
Output is correct |
23 |
Correct |
155 ms |
752 KB |
Output is correct |
24 |
Correct |
144 ms |
496 KB |
Output is correct |
25 |
Correct |
144 ms |
916 KB |
Output is correct |
26 |
Correct |
155 ms |
1096 KB |
Output is correct |
27 |
Correct |
157 ms |
1096 KB |
Output is correct |
28 |
Correct |
146 ms |
584 KB |
Output is correct |
29 |
Correct |
142 ms |
528 KB |
Output is correct |
30 |
Correct |
148 ms |
584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
148 ms |
508 KB |
Output is correct |
32 |
Correct |
143 ms |
532 KB |
Output is correct |
33 |
Correct |
150 ms |
584 KB |
Output is correct |
34 |
Correct |
143 ms |
580 KB |
Output is correct |
35 |
Correct |
145 ms |
584 KB |
Output is correct |
36 |
Correct |
147 ms |
1104 KB |
Output is correct |
37 |
Correct |
155 ms |
584 KB |
Output is correct |
38 |
Correct |
155 ms |
752 KB |
Output is correct |
39 |
Correct |
144 ms |
496 KB |
Output is correct |
40 |
Correct |
144 ms |
916 KB |
Output is correct |
41 |
Correct |
155 ms |
1096 KB |
Output is correct |
42 |
Correct |
157 ms |
1096 KB |
Output is correct |
43 |
Correct |
146 ms |
584 KB |
Output is correct |
44 |
Correct |
142 ms |
528 KB |
Output is correct |
45 |
Correct |
148 ms |
584 KB |
Output is correct |
46 |
Correct |
143 ms |
584 KB |
Output is correct |
47 |
Correct |
143 ms |
584 KB |
Output is correct |
48 |
Correct |
149 ms |
1096 KB |
Output is correct |
49 |
Correct |
156 ms |
1420 KB |
Output is correct |
50 |
Correct |
148 ms |
1096 KB |
Output is correct |
51 |
Correct |
148 ms |
584 KB |
Output is correct |
52 |
Correct |
143 ms |
588 KB |
Output is correct |
53 |
Correct |
149 ms |
744 KB |
Output is correct |
54 |
Correct |
143 ms |
584 KB |
Output is correct |
55 |
Correct |
143 ms |
1224 KB |
Output is correct |
56 |
Correct |
144 ms |
1096 KB |
Output is correct |
57 |
Correct |
145 ms |
1096 KB |
Output is correct |
58 |
Correct |
146 ms |
584 KB |
Output is correct |
59 |
Correct |
143 ms |
584 KB |
Output is correct |
60 |
Correct |
146 ms |
584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
504 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
10 ms |
6272 KB |
Output is correct |
32 |
Correct |
15 ms |
7808 KB |
Output is correct |
33 |
Correct |
10 ms |
6292 KB |
Output is correct |
34 |
Correct |
10 ms |
6288 KB |
Output is correct |
35 |
Correct |
9 ms |
6312 KB |
Output is correct |
36 |
Correct |
9 ms |
6632 KB |
Output is correct |
37 |
Correct |
9 ms |
6632 KB |
Output is correct |
38 |
Correct |
10 ms |
6300 KB |
Output is correct |
39 |
Correct |
9 ms |
6636 KB |
Output is correct |
40 |
Correct |
15 ms |
8116 KB |
Output is correct |
41 |
Correct |
13 ms |
7504 KB |
Output is correct |
42 |
Correct |
11 ms |
6272 KB |
Output is correct |
43 |
Correct |
12 ms |
7916 KB |
Output is correct |
44 |
Correct |
14 ms |
7564 KB |
Output is correct |
45 |
Correct |
13 ms |
7484 KB |
Output is correct |
46 |
Correct |
148 ms |
508 KB |
Output is correct |
47 |
Correct |
143 ms |
532 KB |
Output is correct |
48 |
Correct |
150 ms |
584 KB |
Output is correct |
49 |
Correct |
143 ms |
580 KB |
Output is correct |
50 |
Correct |
145 ms |
584 KB |
Output is correct |
51 |
Correct |
147 ms |
1104 KB |
Output is correct |
52 |
Correct |
155 ms |
584 KB |
Output is correct |
53 |
Correct |
155 ms |
752 KB |
Output is correct |
54 |
Correct |
144 ms |
496 KB |
Output is correct |
55 |
Correct |
144 ms |
916 KB |
Output is correct |
56 |
Correct |
155 ms |
1096 KB |
Output is correct |
57 |
Correct |
157 ms |
1096 KB |
Output is correct |
58 |
Correct |
146 ms |
584 KB |
Output is correct |
59 |
Correct |
142 ms |
528 KB |
Output is correct |
60 |
Correct |
148 ms |
584 KB |
Output is correct |
61 |
Correct |
143 ms |
584 KB |
Output is correct |
62 |
Correct |
143 ms |
584 KB |
Output is correct |
63 |
Correct |
149 ms |
1096 KB |
Output is correct |
64 |
Correct |
156 ms |
1420 KB |
Output is correct |
65 |
Correct |
148 ms |
1096 KB |
Output is correct |
66 |
Correct |
148 ms |
584 KB |
Output is correct |
67 |
Correct |
143 ms |
588 KB |
Output is correct |
68 |
Correct |
149 ms |
744 KB |
Output is correct |
69 |
Correct |
143 ms |
584 KB |
Output is correct |
70 |
Correct |
143 ms |
1224 KB |
Output is correct |
71 |
Correct |
144 ms |
1096 KB |
Output is correct |
72 |
Correct |
145 ms |
1096 KB |
Output is correct |
73 |
Correct |
146 ms |
584 KB |
Output is correct |
74 |
Correct |
143 ms |
584 KB |
Output is correct |
75 |
Correct |
146 ms |
584 KB |
Output is correct |
76 |
Execution timed out |
1050 ms |
8256 KB |
Time limit exceeded |
77 |
Halted |
0 ms |
0 KB |
- |