#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define int long long
#define fio() 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 ort ((bas+son)/2)
#define _ << " " <<
const lo inf = 1000000000;
const lo li = 1000005;
const lo mod = 1000000007;
int n,m,a[li],k,flag,t;
int cev;
string s,ss;
vector<int> v;
inline int fark(int x,int y){
if(x>y)return 26-x+y;
return y-x;
}
inline char ekle(int x,int y){
x+=y;
if(x>'z')x-=26;
return x;
}
struct segtree{
array<int,li*4> tree;
int md=0;
segtree(int x){
md=x;
}
inline void update(int node,int start,int end,int l,int r,int val){
if(start>end || start>r || end<l)return ;
if(start>=l && end<=r){if(md!=start%2)return ;tree[node]+=val;return ;}
update(node*2,start,mid,l,r,val),update(node*2+1,mid+1,end,l,r,val);
tree[node]=tree[node*2]+tree[node*2+1];
}
inline int query(int node,int start,int end,int l,int r){
if(start>end || start>r || end<l)return 0;
if(start>=l && end<=r)return tree[node];
return query(node*2,start,mid,l,r)+query(node*2+1,mid+1,end,l,r);
}
};
int32_t main(void){
fio();
cin>>n>>k;
cin>>s>>ss;
s="%"+s;
ss="%"+ss;
char myc=s[n];
for(int i=1;i<=n-1;i++){
int at=fark(s[i],ss[i]);
a[i]=at;
s[i]=ekle(s[i],at);
s[i+1]=ekle(s[i+1],at);
}
if(s[n]==ss[n]){cout<<"da\n";}
else cout<<"ne\n";
segtree st1(1);
segtree st2(0);
while(k--){
int i;char c;
cin>>i>>c;
if(i==n)myc=c;
int val=a[i-1]+st1.query(1,1,n,1,i-2)*(i%2?-1:1)+st2.query(1,1,n,1,i-2)*(i%2?1:-1)+26*100000000000;
int val2=a[i]+st1.query(1,1,n,1,i-1)*(i%2?1:-1)+st2.query(1,1,n,1,i-1)*(i%2?-1:1)+26*100000000000;
val%=26;val2%=26;
c=ekle(c,val);
int tut=fark(c,ss[i]);
st1.update(1,1,n,i,i,fark(val2,tut));
st2.update(1,1,n,i,i,fark(val2,tut));
val=a[n-1]+st1.query(1,1,n,1,n-2)*(n%2?-1:1)+st2.query(1,1,n,1,n-2)*(n%2?1:-1)+26*100000000000;
val%=26;
//cout<<val _ a[n-1] _ fark(s[n],ss[n])<<" () "<<endl;
if(val==fark(myc,ss[n]))cout<<"da\n";
else cout<<"ne\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
63060 KB |
Output is correct |
2 |
Correct |
29 ms |
63064 KB |
Output is correct |
3 |
Correct |
29 ms |
62800 KB |
Output is correct |
4 |
Correct |
29 ms |
62956 KB |
Output is correct |
5 |
Correct |
30 ms |
62868 KB |
Output is correct |
6 |
Correct |
29 ms |
63064 KB |
Output is correct |
7 |
Correct |
29 ms |
63068 KB |
Output is correct |
8 |
Correct |
28 ms |
62916 KB |
Output is correct |
9 |
Correct |
29 ms |
63060 KB |
Output is correct |
10 |
Correct |
28 ms |
62892 KB |
Output is correct |
11 |
Correct |
33 ms |
63056 KB |
Output is correct |
12 |
Correct |
30 ms |
63064 KB |
Output is correct |
13 |
Correct |
36 ms |
63056 KB |
Output is correct |
14 |
Correct |
29 ms |
62804 KB |
Output is correct |
15 |
Correct |
29 ms |
63068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
63060 KB |
Output is correct |
2 |
Correct |
29 ms |
63064 KB |
Output is correct |
3 |
Correct |
29 ms |
62800 KB |
Output is correct |
4 |
Correct |
29 ms |
62956 KB |
Output is correct |
5 |
Correct |
30 ms |
62868 KB |
Output is correct |
6 |
Correct |
29 ms |
63064 KB |
Output is correct |
7 |
Correct |
29 ms |
63068 KB |
Output is correct |
8 |
Correct |
28 ms |
62916 KB |
Output is correct |
9 |
Correct |
29 ms |
63060 KB |
Output is correct |
10 |
Correct |
28 ms |
62892 KB |
Output is correct |
11 |
Correct |
33 ms |
63056 KB |
Output is correct |
12 |
Correct |
30 ms |
63064 KB |
Output is correct |
13 |
Correct |
36 ms |
63056 KB |
Output is correct |
14 |
Correct |
29 ms |
62804 KB |
Output is correct |
15 |
Correct |
29 ms |
63068 KB |
Output is correct |
16 |
Correct |
28 ms |
63068 KB |
Output is correct |
17 |
Correct |
29 ms |
62852 KB |
Output is correct |
18 |
Correct |
29 ms |
62888 KB |
Output is correct |
19 |
Correct |
29 ms |
63068 KB |
Output is correct |
20 |
Correct |
28 ms |
62824 KB |
Output is correct |
21 |
Correct |
28 ms |
63068 KB |
Output is correct |
22 |
Correct |
32 ms |
63004 KB |
Output is correct |
23 |
Correct |
31 ms |
63068 KB |
Output is correct |
24 |
Correct |
29 ms |
63056 KB |
Output is correct |
25 |
Correct |
47 ms |
63060 KB |
Output is correct |
26 |
Correct |
30 ms |
63028 KB |
Output is correct |
27 |
Correct |
40 ms |
63012 KB |
Output is correct |
28 |
Correct |
28 ms |
63068 KB |
Output is correct |
29 |
Correct |
28 ms |
63068 KB |
Output is correct |
30 |
Correct |
30 ms |
63060 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
63060 KB |
Output is correct |
2 |
Correct |
29 ms |
63064 KB |
Output is correct |
3 |
Correct |
29 ms |
62800 KB |
Output is correct |
4 |
Correct |
29 ms |
62956 KB |
Output is correct |
5 |
Correct |
30 ms |
62868 KB |
Output is correct |
6 |
Correct |
29 ms |
63064 KB |
Output is correct |
7 |
Correct |
29 ms |
63068 KB |
Output is correct |
8 |
Correct |
28 ms |
62916 KB |
Output is correct |
9 |
Correct |
29 ms |
63060 KB |
Output is correct |
10 |
Correct |
28 ms |
62892 KB |
Output is correct |
11 |
Correct |
33 ms |
63056 KB |
Output is correct |
12 |
Correct |
30 ms |
63064 KB |
Output is correct |
13 |
Correct |
36 ms |
63056 KB |
Output is correct |
14 |
Correct |
29 ms |
62804 KB |
Output is correct |
15 |
Correct |
29 ms |
63068 KB |
Output is correct |
16 |
Correct |
28 ms |
63068 KB |
Output is correct |
17 |
Correct |
29 ms |
62852 KB |
Output is correct |
18 |
Correct |
29 ms |
62888 KB |
Output is correct |
19 |
Correct |
29 ms |
63068 KB |
Output is correct |
20 |
Correct |
28 ms |
62824 KB |
Output is correct |
21 |
Correct |
28 ms |
63068 KB |
Output is correct |
22 |
Correct |
32 ms |
63004 KB |
Output is correct |
23 |
Correct |
31 ms |
63068 KB |
Output is correct |
24 |
Correct |
29 ms |
63056 KB |
Output is correct |
25 |
Correct |
47 ms |
63060 KB |
Output is correct |
26 |
Correct |
30 ms |
63028 KB |
Output is correct |
27 |
Correct |
40 ms |
63012 KB |
Output is correct |
28 |
Correct |
28 ms |
63068 KB |
Output is correct |
29 |
Correct |
28 ms |
63068 KB |
Output is correct |
30 |
Correct |
30 ms |
63060 KB |
Output is correct |
31 |
Correct |
39 ms |
72672 KB |
Output is correct |
32 |
Correct |
40 ms |
72676 KB |
Output is correct |
33 |
Correct |
41 ms |
72824 KB |
Output is correct |
34 |
Correct |
42 ms |
72684 KB |
Output is correct |
35 |
Correct |
38 ms |
72668 KB |
Output is correct |
36 |
Correct |
39 ms |
72788 KB |
Output is correct |
37 |
Correct |
40 ms |
72780 KB |
Output is correct |
38 |
Correct |
64 ms |
72636 KB |
Output is correct |
39 |
Correct |
38 ms |
72784 KB |
Output is correct |
40 |
Correct |
39 ms |
72648 KB |
Output is correct |
41 |
Correct |
42 ms |
72676 KB |
Output is correct |
42 |
Correct |
38 ms |
72664 KB |
Output is correct |
43 |
Correct |
37 ms |
72868 KB |
Output is correct |
44 |
Correct |
40 ms |
72708 KB |
Output is correct |
45 |
Correct |
50 ms |
72676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
63060 KB |
Output is correct |
2 |
Correct |
29 ms |
63064 KB |
Output is correct |
3 |
Correct |
29 ms |
62800 KB |
Output is correct |
4 |
Correct |
29 ms |
62956 KB |
Output is correct |
5 |
Correct |
30 ms |
62868 KB |
Output is correct |
6 |
Correct |
29 ms |
63064 KB |
Output is correct |
7 |
Correct |
29 ms |
63068 KB |
Output is correct |
8 |
Correct |
28 ms |
62916 KB |
Output is correct |
9 |
Correct |
29 ms |
63060 KB |
Output is correct |
10 |
Correct |
28 ms |
62892 KB |
Output is correct |
11 |
Correct |
33 ms |
63056 KB |
Output is correct |
12 |
Correct |
30 ms |
63064 KB |
Output is correct |
13 |
Correct |
36 ms |
63056 KB |
Output is correct |
14 |
Correct |
29 ms |
62804 KB |
Output is correct |
15 |
Correct |
29 ms |
63068 KB |
Output is correct |
16 |
Incorrect |
41 ms |
63124 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
63060 KB |
Output is correct |
2 |
Correct |
29 ms |
63064 KB |
Output is correct |
3 |
Correct |
29 ms |
62800 KB |
Output is correct |
4 |
Correct |
29 ms |
62956 KB |
Output is correct |
5 |
Correct |
30 ms |
62868 KB |
Output is correct |
6 |
Correct |
29 ms |
63064 KB |
Output is correct |
7 |
Correct |
29 ms |
63068 KB |
Output is correct |
8 |
Correct |
28 ms |
62916 KB |
Output is correct |
9 |
Correct |
29 ms |
63060 KB |
Output is correct |
10 |
Correct |
28 ms |
62892 KB |
Output is correct |
11 |
Correct |
33 ms |
63056 KB |
Output is correct |
12 |
Correct |
30 ms |
63064 KB |
Output is correct |
13 |
Correct |
36 ms |
63056 KB |
Output is correct |
14 |
Correct |
29 ms |
62804 KB |
Output is correct |
15 |
Correct |
29 ms |
63068 KB |
Output is correct |
16 |
Correct |
28 ms |
63068 KB |
Output is correct |
17 |
Correct |
29 ms |
62852 KB |
Output is correct |
18 |
Correct |
29 ms |
62888 KB |
Output is correct |
19 |
Correct |
29 ms |
63068 KB |
Output is correct |
20 |
Correct |
28 ms |
62824 KB |
Output is correct |
21 |
Correct |
28 ms |
63068 KB |
Output is correct |
22 |
Correct |
32 ms |
63004 KB |
Output is correct |
23 |
Correct |
31 ms |
63068 KB |
Output is correct |
24 |
Correct |
29 ms |
63056 KB |
Output is correct |
25 |
Correct |
47 ms |
63060 KB |
Output is correct |
26 |
Correct |
30 ms |
63028 KB |
Output is correct |
27 |
Correct |
40 ms |
63012 KB |
Output is correct |
28 |
Correct |
28 ms |
63068 KB |
Output is correct |
29 |
Correct |
28 ms |
63068 KB |
Output is correct |
30 |
Correct |
30 ms |
63060 KB |
Output is correct |
31 |
Incorrect |
41 ms |
63124 KB |
Output isn't correct |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
63060 KB |
Output is correct |
2 |
Correct |
29 ms |
63064 KB |
Output is correct |
3 |
Correct |
29 ms |
62800 KB |
Output is correct |
4 |
Correct |
29 ms |
62956 KB |
Output is correct |
5 |
Correct |
30 ms |
62868 KB |
Output is correct |
6 |
Correct |
29 ms |
63064 KB |
Output is correct |
7 |
Correct |
29 ms |
63068 KB |
Output is correct |
8 |
Correct |
28 ms |
62916 KB |
Output is correct |
9 |
Correct |
29 ms |
63060 KB |
Output is correct |
10 |
Correct |
28 ms |
62892 KB |
Output is correct |
11 |
Correct |
33 ms |
63056 KB |
Output is correct |
12 |
Correct |
30 ms |
63064 KB |
Output is correct |
13 |
Correct |
36 ms |
63056 KB |
Output is correct |
14 |
Correct |
29 ms |
62804 KB |
Output is correct |
15 |
Correct |
29 ms |
63068 KB |
Output is correct |
16 |
Correct |
28 ms |
63068 KB |
Output is correct |
17 |
Correct |
29 ms |
62852 KB |
Output is correct |
18 |
Correct |
29 ms |
62888 KB |
Output is correct |
19 |
Correct |
29 ms |
63068 KB |
Output is correct |
20 |
Correct |
28 ms |
62824 KB |
Output is correct |
21 |
Correct |
28 ms |
63068 KB |
Output is correct |
22 |
Correct |
32 ms |
63004 KB |
Output is correct |
23 |
Correct |
31 ms |
63068 KB |
Output is correct |
24 |
Correct |
29 ms |
63056 KB |
Output is correct |
25 |
Correct |
47 ms |
63060 KB |
Output is correct |
26 |
Correct |
30 ms |
63028 KB |
Output is correct |
27 |
Correct |
40 ms |
63012 KB |
Output is correct |
28 |
Correct |
28 ms |
63068 KB |
Output is correct |
29 |
Correct |
28 ms |
63068 KB |
Output is correct |
30 |
Correct |
30 ms |
63060 KB |
Output is correct |
31 |
Correct |
39 ms |
72672 KB |
Output is correct |
32 |
Correct |
40 ms |
72676 KB |
Output is correct |
33 |
Correct |
41 ms |
72824 KB |
Output is correct |
34 |
Correct |
42 ms |
72684 KB |
Output is correct |
35 |
Correct |
38 ms |
72668 KB |
Output is correct |
36 |
Correct |
39 ms |
72788 KB |
Output is correct |
37 |
Correct |
40 ms |
72780 KB |
Output is correct |
38 |
Correct |
64 ms |
72636 KB |
Output is correct |
39 |
Correct |
38 ms |
72784 KB |
Output is correct |
40 |
Correct |
39 ms |
72648 KB |
Output is correct |
41 |
Correct |
42 ms |
72676 KB |
Output is correct |
42 |
Correct |
38 ms |
72664 KB |
Output is correct |
43 |
Correct |
37 ms |
72868 KB |
Output is correct |
44 |
Correct |
40 ms |
72708 KB |
Output is correct |
45 |
Correct |
50 ms |
72676 KB |
Output is correct |
46 |
Incorrect |
41 ms |
63124 KB |
Output isn't correct |
47 |
Halted |
0 ms |
0 KB |
- |