#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY LLONG_MAX
#define mod 998244353
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define lim 1000005
#define fi first
#define se second
int dizi[lim];
int pre[lim];
int32_t main(){
faster
int n,q;cin>>n>>q;
string a,b;cin>>a>>b;
FOR{
dizi[i]=b[i-1]-a[i-1];
}
FOR{
if(i==1)continue;
if(i==2){
pre[i]=dizi[i]-dizi[i-1];
pre[i]=(pre[i]+26)%26;
continue;
}
pre[i]=dizi[i]-pre[i-1];
pre[i]=(pre[i]+26)%26;
//cout<<pre[i]<<endl;
}
if(n==1 && a!=b){
cout<<"ne"<<'\n';
return 0;
}
else if(n==1 && a==b){
cout<<"da"<<'\n';
return 0;
}
if(pre[n]==0){
cout<<"da"<<'\n';
}
else cout<<"ne"<<'\n';
while(q--){
int pos;char c;
cin>>pos>>c;
if(n==1){
a=c;
if(a==b){
cout<<"da"<<'\n';
}
else{
cout<<"ne"<<'\n';
}
continue;
}
dizi[pos]=(b[pos-1]-c+26)%26;
//cout<<pos<<" "<<dizi[pos]<<" "<<dizi[pos+1]<<endl;
for(int i=pos;i<=n;i++){
if(i==1)continue;
if(i==2){
pre[i]=dizi[i]-dizi[i-1];
pre[i]=(pre[i]+26)%26;
continue;
}
pre[i]=dizi[i]-pre[i-1];
pre[i]=(pre[i]+26)%26;
}
/*for(int i=1;i<=n;i++){
cout<<dizi[i]<<" ";
}
cout<<'\n';
for(int i=1;i<=n;i++){
cout<<pre[i]<<" ";
}
cout<<'\n';*/
if(pre[n]==0){
cout<<"da"<<'\n';
}
else cout<<"ne"<<'\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2396 KB |
Output is correct |
15 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2396 KB |
Output is correct |
15 |
Correct |
0 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2440 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
0 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
0 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
1 ms |
2396 KB |
Output is correct |
26 |
Correct |
0 ms |
2396 KB |
Output is correct |
27 |
Correct |
0 ms |
2396 KB |
Output is correct |
28 |
Correct |
0 ms |
2396 KB |
Output is correct |
29 |
Correct |
0 ms |
2396 KB |
Output is correct |
30 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2396 KB |
Output is correct |
15 |
Correct |
0 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2440 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
0 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
0 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
1 ms |
2396 KB |
Output is correct |
26 |
Correct |
0 ms |
2396 KB |
Output is correct |
27 |
Correct |
0 ms |
2396 KB |
Output is correct |
28 |
Correct |
0 ms |
2396 KB |
Output is correct |
29 |
Correct |
0 ms |
2396 KB |
Output is correct |
30 |
Correct |
0 ms |
2396 KB |
Output is correct |
31 |
Correct |
9 ms |
18060 KB |
Output is correct |
32 |
Correct |
9 ms |
18060 KB |
Output is correct |
33 |
Correct |
9 ms |
18148 KB |
Output is correct |
34 |
Correct |
8 ms |
18076 KB |
Output is correct |
35 |
Correct |
9 ms |
18060 KB |
Output is correct |
36 |
Correct |
8 ms |
18420 KB |
Output is correct |
37 |
Correct |
8 ms |
18588 KB |
Output is correct |
38 |
Correct |
9 ms |
18076 KB |
Output is correct |
39 |
Correct |
9 ms |
18680 KB |
Output is correct |
40 |
Correct |
9 ms |
18412 KB |
Output is correct |
41 |
Correct |
8 ms |
18072 KB |
Output is correct |
42 |
Correct |
9 ms |
18072 KB |
Output is correct |
43 |
Correct |
9 ms |
18388 KB |
Output is correct |
44 |
Correct |
9 ms |
18092 KB |
Output is correct |
45 |
Correct |
9 ms |
18192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2396 KB |
Output is correct |
15 |
Correct |
0 ms |
2396 KB |
Output is correct |
16 |
Correct |
9 ms |
2652 KB |
Output is correct |
17 |
Correct |
9 ms |
2704 KB |
Output is correct |
18 |
Correct |
10 ms |
2652 KB |
Output is correct |
19 |
Correct |
9 ms |
2652 KB |
Output is correct |
20 |
Correct |
13 ms |
2652 KB |
Output is correct |
21 |
Correct |
9 ms |
2652 KB |
Output is correct |
22 |
Correct |
9 ms |
2584 KB |
Output is correct |
23 |
Correct |
10 ms |
2648 KB |
Output is correct |
24 |
Correct |
10 ms |
2652 KB |
Output is correct |
25 |
Correct |
10 ms |
2652 KB |
Output is correct |
26 |
Correct |
9 ms |
2652 KB |
Output is correct |
27 |
Correct |
9 ms |
2652 KB |
Output is correct |
28 |
Correct |
9 ms |
2652 KB |
Output is correct |
29 |
Correct |
9 ms |
2576 KB |
Output is correct |
30 |
Correct |
9 ms |
2648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2396 KB |
Output is correct |
15 |
Correct |
0 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2440 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
0 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
0 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
1 ms |
2396 KB |
Output is correct |
26 |
Correct |
0 ms |
2396 KB |
Output is correct |
27 |
Correct |
0 ms |
2396 KB |
Output is correct |
28 |
Correct |
0 ms |
2396 KB |
Output is correct |
29 |
Correct |
0 ms |
2396 KB |
Output is correct |
30 |
Correct |
0 ms |
2396 KB |
Output is correct |
31 |
Correct |
9 ms |
2652 KB |
Output is correct |
32 |
Correct |
9 ms |
2704 KB |
Output is correct |
33 |
Correct |
10 ms |
2652 KB |
Output is correct |
34 |
Correct |
9 ms |
2652 KB |
Output is correct |
35 |
Correct |
13 ms |
2652 KB |
Output is correct |
36 |
Correct |
9 ms |
2652 KB |
Output is correct |
37 |
Correct |
9 ms |
2584 KB |
Output is correct |
38 |
Correct |
10 ms |
2648 KB |
Output is correct |
39 |
Correct |
10 ms |
2652 KB |
Output is correct |
40 |
Correct |
10 ms |
2652 KB |
Output is correct |
41 |
Correct |
9 ms |
2652 KB |
Output is correct |
42 |
Correct |
9 ms |
2652 KB |
Output is correct |
43 |
Correct |
9 ms |
2652 KB |
Output is correct |
44 |
Correct |
9 ms |
2576 KB |
Output is correct |
45 |
Correct |
9 ms |
2648 KB |
Output is correct |
46 |
Correct |
205 ms |
2644 KB |
Output is correct |
47 |
Correct |
206 ms |
2784 KB |
Output is correct |
48 |
Correct |
194 ms |
2644 KB |
Output is correct |
49 |
Correct |
200 ms |
2776 KB |
Output is correct |
50 |
Correct |
202 ms |
2640 KB |
Output is correct |
51 |
Correct |
198 ms |
2640 KB |
Output is correct |
52 |
Correct |
204 ms |
2640 KB |
Output is correct |
53 |
Correct |
190 ms |
2640 KB |
Output is correct |
54 |
Correct |
201 ms |
2640 KB |
Output is correct |
55 |
Correct |
200 ms |
2624 KB |
Output is correct |
56 |
Correct |
190 ms |
2640 KB |
Output is correct |
57 |
Correct |
191 ms |
2640 KB |
Output is correct |
58 |
Correct |
193 ms |
2640 KB |
Output is correct |
59 |
Correct |
196 ms |
2644 KB |
Output is correct |
60 |
Correct |
196 ms |
2640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2396 KB |
Output is correct |
15 |
Correct |
0 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2440 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
0 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
0 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
1 ms |
2396 KB |
Output is correct |
26 |
Correct |
0 ms |
2396 KB |
Output is correct |
27 |
Correct |
0 ms |
2396 KB |
Output is correct |
28 |
Correct |
0 ms |
2396 KB |
Output is correct |
29 |
Correct |
0 ms |
2396 KB |
Output is correct |
30 |
Correct |
0 ms |
2396 KB |
Output is correct |
31 |
Correct |
9 ms |
18060 KB |
Output is correct |
32 |
Correct |
9 ms |
18060 KB |
Output is correct |
33 |
Correct |
9 ms |
18148 KB |
Output is correct |
34 |
Correct |
8 ms |
18076 KB |
Output is correct |
35 |
Correct |
9 ms |
18060 KB |
Output is correct |
36 |
Correct |
8 ms |
18420 KB |
Output is correct |
37 |
Correct |
8 ms |
18588 KB |
Output is correct |
38 |
Correct |
9 ms |
18076 KB |
Output is correct |
39 |
Correct |
9 ms |
18680 KB |
Output is correct |
40 |
Correct |
9 ms |
18412 KB |
Output is correct |
41 |
Correct |
8 ms |
18072 KB |
Output is correct |
42 |
Correct |
9 ms |
18072 KB |
Output is correct |
43 |
Correct |
9 ms |
18388 KB |
Output is correct |
44 |
Correct |
9 ms |
18092 KB |
Output is correct |
45 |
Correct |
9 ms |
18192 KB |
Output is correct |
46 |
Correct |
9 ms |
2652 KB |
Output is correct |
47 |
Correct |
9 ms |
2704 KB |
Output is correct |
48 |
Correct |
10 ms |
2652 KB |
Output is correct |
49 |
Correct |
9 ms |
2652 KB |
Output is correct |
50 |
Correct |
13 ms |
2652 KB |
Output is correct |
51 |
Correct |
9 ms |
2652 KB |
Output is correct |
52 |
Correct |
9 ms |
2584 KB |
Output is correct |
53 |
Correct |
10 ms |
2648 KB |
Output is correct |
54 |
Correct |
10 ms |
2652 KB |
Output is correct |
55 |
Correct |
10 ms |
2652 KB |
Output is correct |
56 |
Correct |
9 ms |
2652 KB |
Output is correct |
57 |
Correct |
9 ms |
2652 KB |
Output is correct |
58 |
Correct |
9 ms |
2652 KB |
Output is correct |
59 |
Correct |
9 ms |
2576 KB |
Output is correct |
60 |
Correct |
9 ms |
2648 KB |
Output is correct |
61 |
Correct |
205 ms |
2644 KB |
Output is correct |
62 |
Correct |
206 ms |
2784 KB |
Output is correct |
63 |
Correct |
194 ms |
2644 KB |
Output is correct |
64 |
Correct |
200 ms |
2776 KB |
Output is correct |
65 |
Correct |
202 ms |
2640 KB |
Output is correct |
66 |
Correct |
198 ms |
2640 KB |
Output is correct |
67 |
Correct |
204 ms |
2640 KB |
Output is correct |
68 |
Correct |
190 ms |
2640 KB |
Output is correct |
69 |
Correct |
201 ms |
2640 KB |
Output is correct |
70 |
Correct |
200 ms |
2624 KB |
Output is correct |
71 |
Correct |
190 ms |
2640 KB |
Output is correct |
72 |
Correct |
191 ms |
2640 KB |
Output is correct |
73 |
Correct |
193 ms |
2640 KB |
Output is correct |
74 |
Correct |
196 ms |
2644 KB |
Output is correct |
75 |
Correct |
196 ms |
2640 KB |
Output is correct |
76 |
Execution timed out |
1092 ms |
18060 KB |
Time limit exceeded |
77 |
Halted |
0 ms |
0 KB |
- |