#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PB push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F first
#define S second
#define PB push_back
// void setIO(string s) {
// freopen((s + ".in").c_str(), "r", stdin);
// freopen((s + ".out").c_str(), "w", stdout);
// }
void solve(){
int n, q; cin >> n >> q;
string a, b; cin >> a >> b;
string x = a, y = b;
for(int i = 0; i <= q; i++){
if(i){
int p; cin >> p;
p--;
char c; cin >> c;
x[p] = c;
}
a = x, b = y;
for(int i = n-1; i > 0; i--){
if(a[i] <= b[i]){
int d = b[i]-a[i];
a[i] = b[i];
a[i-1] = char( ((a[i-1]-'a'+d)%26) + 'a');
}else{
int d = a[i]-b[i];
b[i] = a[i];
b[i-1] = char( ((b[i-1]-'a'+d)%26) + 'a');
}
}
cout << (a==b?"da":"ne") << '\n';
}
}
int main(){
ios_base::sync_with_stdio(false), cout.tie(NULL), cin.tie(NULL);
// setIO("");
int testcase = 1;
// cin >> testcase;
for(int i = 1; i <= testcase; i++){
// cout << "Case " << i << ": ";
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
16 ms |
4492 KB |
Output is correct |
32 |
Correct |
16 ms |
4492 KB |
Output is correct |
33 |
Correct |
16 ms |
4512 KB |
Output is correct |
34 |
Correct |
16 ms |
4508 KB |
Output is correct |
35 |
Correct |
14 ms |
4508 KB |
Output is correct |
36 |
Correct |
16 ms |
4852 KB |
Output is correct |
37 |
Correct |
15 ms |
4852 KB |
Output is correct |
38 |
Correct |
16 ms |
4508 KB |
Output is correct |
39 |
Correct |
16 ms |
4852 KB |
Output is correct |
40 |
Correct |
15 ms |
4844 KB |
Output is correct |
41 |
Correct |
17 ms |
4504 KB |
Output is correct |
42 |
Correct |
16 ms |
4492 KB |
Output is correct |
43 |
Correct |
15 ms |
4892 KB |
Output is correct |
44 |
Correct |
15 ms |
4524 KB |
Output is correct |
45 |
Correct |
15 ms |
4500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
13 ms |
604 KB |
Output is correct |
17 |
Correct |
13 ms |
600 KB |
Output is correct |
18 |
Correct |
12 ms |
756 KB |
Output is correct |
19 |
Correct |
14 ms |
604 KB |
Output is correct |
20 |
Correct |
14 ms |
688 KB |
Output is correct |
21 |
Correct |
13 ms |
600 KB |
Output is correct |
22 |
Correct |
12 ms |
604 KB |
Output is correct |
23 |
Correct |
12 ms |
604 KB |
Output is correct |
24 |
Correct |
12 ms |
604 KB |
Output is correct |
25 |
Correct |
13 ms |
604 KB |
Output is correct |
26 |
Correct |
13 ms |
532 KB |
Output is correct |
27 |
Correct |
13 ms |
604 KB |
Output is correct |
28 |
Correct |
12 ms |
856 KB |
Output is correct |
29 |
Correct |
13 ms |
600 KB |
Output is correct |
30 |
Correct |
13 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
13 ms |
604 KB |
Output is correct |
32 |
Correct |
13 ms |
600 KB |
Output is correct |
33 |
Correct |
12 ms |
756 KB |
Output is correct |
34 |
Correct |
14 ms |
604 KB |
Output is correct |
35 |
Correct |
14 ms |
688 KB |
Output is correct |
36 |
Correct |
13 ms |
600 KB |
Output is correct |
37 |
Correct |
12 ms |
604 KB |
Output is correct |
38 |
Correct |
12 ms |
604 KB |
Output is correct |
39 |
Correct |
12 ms |
604 KB |
Output is correct |
40 |
Correct |
13 ms |
604 KB |
Output is correct |
41 |
Correct |
13 ms |
532 KB |
Output is correct |
42 |
Correct |
13 ms |
604 KB |
Output is correct |
43 |
Correct |
12 ms |
856 KB |
Output is correct |
44 |
Correct |
13 ms |
600 KB |
Output is correct |
45 |
Correct |
13 ms |
604 KB |
Output is correct |
46 |
Correct |
844 ms |
592 KB |
Output is correct |
47 |
Correct |
835 ms |
596 KB |
Output is correct |
48 |
Correct |
812 ms |
720 KB |
Output is correct |
49 |
Correct |
808 ms |
712 KB |
Output is correct |
50 |
Correct |
826 ms |
716 KB |
Output is correct |
51 |
Correct |
817 ms |
712 KB |
Output is correct |
52 |
Correct |
814 ms |
712 KB |
Output is correct |
53 |
Correct |
803 ms |
592 KB |
Output is correct |
54 |
Correct |
819 ms |
716 KB |
Output is correct |
55 |
Correct |
812 ms |
596 KB |
Output is correct |
56 |
Correct |
770 ms |
548 KB |
Output is correct |
57 |
Correct |
813 ms |
716 KB |
Output is correct |
58 |
Correct |
828 ms |
712 KB |
Output is correct |
59 |
Correct |
841 ms |
596 KB |
Output is correct |
60 |
Correct |
822 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
16 ms |
4492 KB |
Output is correct |
32 |
Correct |
16 ms |
4492 KB |
Output is correct |
33 |
Correct |
16 ms |
4512 KB |
Output is correct |
34 |
Correct |
16 ms |
4508 KB |
Output is correct |
35 |
Correct |
14 ms |
4508 KB |
Output is correct |
36 |
Correct |
16 ms |
4852 KB |
Output is correct |
37 |
Correct |
15 ms |
4852 KB |
Output is correct |
38 |
Correct |
16 ms |
4508 KB |
Output is correct |
39 |
Correct |
16 ms |
4852 KB |
Output is correct |
40 |
Correct |
15 ms |
4844 KB |
Output is correct |
41 |
Correct |
17 ms |
4504 KB |
Output is correct |
42 |
Correct |
16 ms |
4492 KB |
Output is correct |
43 |
Correct |
15 ms |
4892 KB |
Output is correct |
44 |
Correct |
15 ms |
4524 KB |
Output is correct |
45 |
Correct |
15 ms |
4500 KB |
Output is correct |
46 |
Correct |
13 ms |
604 KB |
Output is correct |
47 |
Correct |
13 ms |
600 KB |
Output is correct |
48 |
Correct |
12 ms |
756 KB |
Output is correct |
49 |
Correct |
14 ms |
604 KB |
Output is correct |
50 |
Correct |
14 ms |
688 KB |
Output is correct |
51 |
Correct |
13 ms |
600 KB |
Output is correct |
52 |
Correct |
12 ms |
604 KB |
Output is correct |
53 |
Correct |
12 ms |
604 KB |
Output is correct |
54 |
Correct |
12 ms |
604 KB |
Output is correct |
55 |
Correct |
13 ms |
604 KB |
Output is correct |
56 |
Correct |
13 ms |
532 KB |
Output is correct |
57 |
Correct |
13 ms |
604 KB |
Output is correct |
58 |
Correct |
12 ms |
856 KB |
Output is correct |
59 |
Correct |
13 ms |
600 KB |
Output is correct |
60 |
Correct |
13 ms |
604 KB |
Output is correct |
61 |
Correct |
844 ms |
592 KB |
Output is correct |
62 |
Correct |
835 ms |
596 KB |
Output is correct |
63 |
Correct |
812 ms |
720 KB |
Output is correct |
64 |
Correct |
808 ms |
712 KB |
Output is correct |
65 |
Correct |
826 ms |
716 KB |
Output is correct |
66 |
Correct |
817 ms |
712 KB |
Output is correct |
67 |
Correct |
814 ms |
712 KB |
Output is correct |
68 |
Correct |
803 ms |
592 KB |
Output is correct |
69 |
Correct |
819 ms |
716 KB |
Output is correct |
70 |
Correct |
812 ms |
596 KB |
Output is correct |
71 |
Correct |
770 ms |
548 KB |
Output is correct |
72 |
Correct |
813 ms |
716 KB |
Output is correct |
73 |
Correct |
828 ms |
712 KB |
Output is correct |
74 |
Correct |
841 ms |
596 KB |
Output is correct |
75 |
Correct |
822 ms |
592 KB |
Output is correct |
76 |
Execution timed out |
1050 ms |
4492 KB |
Time limit exceeded |
77 |
Halted |
0 ms |
0 KB |
- |