#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,st;
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{
vector<int> 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;
st=s;
char myc=s[n];
for(int i=1;i<=n-1;i++){
int at=fark(s[i],ss[i]);
a[i]=at;
//~ cout<<i _ a[i] _ "!!\n";
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";
//~ cerr<<1<<endl;
segtree st1(1);
st1.tree.resize(li*4);
segtree st2(0);
st2.tree.resize(li*4);
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,tut-val2);
//~ st2.update(1,1,n,i,i,tut-val2);
//~ a[i]=tut-val;
//~ st1.update(1,1,n,i,i,fark(st[i],c));
//~ st2.update(1,1,n,i,i,fark(st[i],c));
st1.update(1,1,n,i,i,fark(c,st[i]));
st2.update(1,1,n,i,i,fark(c,st[i]));
st[i]=c;
int val=a[n-1]+st1.query(1,1,n,1,n-1)*(n%2?-1:1)+st2.query(1,1,n,1,n-1)*(n%2?1:-1)+26*100000000000;
val%=26;
//~ cout<<tut _ val _ a[n-1] _ fark(myc,ss[n])<<" () "<<endl;
if(val==fark(myc,ss[n]))cout<<"da\n";
else cout<<"ne\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
63320 KB |
Output is correct |
2 |
Correct |
9 ms |
63064 KB |
Output is correct |
3 |
Correct |
7 ms |
63068 KB |
Output is correct |
4 |
Correct |
7 ms |
62984 KB |
Output is correct |
5 |
Correct |
7 ms |
62884 KB |
Output is correct |
6 |
Correct |
8 ms |
63068 KB |
Output is correct |
7 |
Correct |
8 ms |
63052 KB |
Output is correct |
8 |
Correct |
7 ms |
63068 KB |
Output is correct |
9 |
Correct |
8 ms |
63064 KB |
Output is correct |
10 |
Correct |
10 ms |
63092 KB |
Output is correct |
11 |
Correct |
8 ms |
63020 KB |
Output is correct |
12 |
Correct |
9 ms |
63068 KB |
Output is correct |
13 |
Correct |
8 ms |
62868 KB |
Output is correct |
14 |
Correct |
7 ms |
63068 KB |
Output is correct |
15 |
Correct |
8 ms |
63068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
63320 KB |
Output is correct |
2 |
Correct |
9 ms |
63064 KB |
Output is correct |
3 |
Correct |
7 ms |
63068 KB |
Output is correct |
4 |
Correct |
7 ms |
62984 KB |
Output is correct |
5 |
Correct |
7 ms |
62884 KB |
Output is correct |
6 |
Correct |
8 ms |
63068 KB |
Output is correct |
7 |
Correct |
8 ms |
63052 KB |
Output is correct |
8 |
Correct |
7 ms |
63068 KB |
Output is correct |
9 |
Correct |
8 ms |
63064 KB |
Output is correct |
10 |
Correct |
10 ms |
63092 KB |
Output is correct |
11 |
Correct |
8 ms |
63020 KB |
Output is correct |
12 |
Correct |
9 ms |
63068 KB |
Output is correct |
13 |
Correct |
8 ms |
62868 KB |
Output is correct |
14 |
Correct |
7 ms |
63068 KB |
Output is correct |
15 |
Correct |
8 ms |
63068 KB |
Output is correct |
16 |
Correct |
8 ms |
63068 KB |
Output is correct |
17 |
Correct |
9 ms |
63100 KB |
Output is correct |
18 |
Correct |
8 ms |
63068 KB |
Output is correct |
19 |
Correct |
8 ms |
63068 KB |
Output is correct |
20 |
Correct |
8 ms |
63068 KB |
Output is correct |
21 |
Correct |
9 ms |
63068 KB |
Output is correct |
22 |
Correct |
7 ms |
63048 KB |
Output is correct |
23 |
Correct |
8 ms |
63068 KB |
Output is correct |
24 |
Correct |
8 ms |
63068 KB |
Output is correct |
25 |
Correct |
8 ms |
63068 KB |
Output is correct |
26 |
Correct |
8 ms |
63068 KB |
Output is correct |
27 |
Correct |
10 ms |
62884 KB |
Output is correct |
28 |
Correct |
9 ms |
63064 KB |
Output is correct |
29 |
Correct |
9 ms |
63068 KB |
Output is correct |
30 |
Correct |
9 ms |
63044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
63320 KB |
Output is correct |
2 |
Correct |
9 ms |
63064 KB |
Output is correct |
3 |
Correct |
7 ms |
63068 KB |
Output is correct |
4 |
Correct |
7 ms |
62984 KB |
Output is correct |
5 |
Correct |
7 ms |
62884 KB |
Output is correct |
6 |
Correct |
8 ms |
63068 KB |
Output is correct |
7 |
Correct |
8 ms |
63052 KB |
Output is correct |
8 |
Correct |
7 ms |
63068 KB |
Output is correct |
9 |
Correct |
8 ms |
63064 KB |
Output is correct |
10 |
Correct |
10 ms |
63092 KB |
Output is correct |
11 |
Correct |
8 ms |
63020 KB |
Output is correct |
12 |
Correct |
9 ms |
63068 KB |
Output is correct |
13 |
Correct |
8 ms |
62868 KB |
Output is correct |
14 |
Correct |
7 ms |
63068 KB |
Output is correct |
15 |
Correct |
8 ms |
63068 KB |
Output is correct |
16 |
Correct |
8 ms |
63068 KB |
Output is correct |
17 |
Correct |
9 ms |
63100 KB |
Output is correct |
18 |
Correct |
8 ms |
63068 KB |
Output is correct |
19 |
Correct |
8 ms |
63068 KB |
Output is correct |
20 |
Correct |
8 ms |
63068 KB |
Output is correct |
21 |
Correct |
9 ms |
63068 KB |
Output is correct |
22 |
Correct |
7 ms |
63048 KB |
Output is correct |
23 |
Correct |
8 ms |
63068 KB |
Output is correct |
24 |
Correct |
8 ms |
63068 KB |
Output is correct |
25 |
Correct |
8 ms |
63068 KB |
Output is correct |
26 |
Correct |
8 ms |
63068 KB |
Output is correct |
27 |
Correct |
10 ms |
62884 KB |
Output is correct |
28 |
Correct |
9 ms |
63064 KB |
Output is correct |
29 |
Correct |
9 ms |
63068 KB |
Output is correct |
30 |
Correct |
9 ms |
63044 KB |
Output is correct |
31 |
Correct |
19 ms |
73704 KB |
Output is correct |
32 |
Correct |
19 ms |
73708 KB |
Output is correct |
33 |
Correct |
19 ms |
73720 KB |
Output is correct |
34 |
Correct |
20 ms |
73696 KB |
Output is correct |
35 |
Correct |
20 ms |
73696 KB |
Output is correct |
36 |
Correct |
19 ms |
73800 KB |
Output is correct |
37 |
Correct |
20 ms |
73740 KB |
Output is correct |
38 |
Correct |
23 ms |
73716 KB |
Output is correct |
39 |
Correct |
20 ms |
73768 KB |
Output is correct |
40 |
Correct |
18 ms |
73804 KB |
Output is correct |
41 |
Correct |
23 ms |
73856 KB |
Output is correct |
42 |
Correct |
20 ms |
73700 KB |
Output is correct |
43 |
Correct |
20 ms |
73744 KB |
Output is correct |
44 |
Correct |
22 ms |
73648 KB |
Output is correct |
45 |
Correct |
19 ms |
73708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
63320 KB |
Output is correct |
2 |
Correct |
9 ms |
63064 KB |
Output is correct |
3 |
Correct |
7 ms |
63068 KB |
Output is correct |
4 |
Correct |
7 ms |
62984 KB |
Output is correct |
5 |
Correct |
7 ms |
62884 KB |
Output is correct |
6 |
Correct |
8 ms |
63068 KB |
Output is correct |
7 |
Correct |
8 ms |
63052 KB |
Output is correct |
8 |
Correct |
7 ms |
63068 KB |
Output is correct |
9 |
Correct |
8 ms |
63064 KB |
Output is correct |
10 |
Correct |
10 ms |
63092 KB |
Output is correct |
11 |
Correct |
8 ms |
63020 KB |
Output is correct |
12 |
Correct |
9 ms |
63068 KB |
Output is correct |
13 |
Correct |
8 ms |
62868 KB |
Output is correct |
14 |
Correct |
7 ms |
63068 KB |
Output is correct |
15 |
Correct |
8 ms |
63068 KB |
Output is correct |
16 |
Correct |
20 ms |
63396 KB |
Output is correct |
17 |
Correct |
19 ms |
63736 KB |
Output is correct |
18 |
Correct |
19 ms |
63580 KB |
Output is correct |
19 |
Correct |
20 ms |
63580 KB |
Output is correct |
20 |
Correct |
20 ms |
63580 KB |
Output is correct |
21 |
Correct |
20 ms |
63580 KB |
Output is correct |
22 |
Correct |
20 ms |
63624 KB |
Output is correct |
23 |
Correct |
19 ms |
63700 KB |
Output is correct |
24 |
Correct |
18 ms |
63580 KB |
Output is correct |
25 |
Correct |
21 ms |
63576 KB |
Output is correct |
26 |
Correct |
19 ms |
63740 KB |
Output is correct |
27 |
Correct |
19 ms |
63576 KB |
Output is correct |
28 |
Correct |
24 ms |
63836 KB |
Output is correct |
29 |
Correct |
24 ms |
63592 KB |
Output is correct |
30 |
Correct |
20 ms |
63676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
63320 KB |
Output is correct |
2 |
Correct |
9 ms |
63064 KB |
Output is correct |
3 |
Correct |
7 ms |
63068 KB |
Output is correct |
4 |
Correct |
7 ms |
62984 KB |
Output is correct |
5 |
Correct |
7 ms |
62884 KB |
Output is correct |
6 |
Correct |
8 ms |
63068 KB |
Output is correct |
7 |
Correct |
8 ms |
63052 KB |
Output is correct |
8 |
Correct |
7 ms |
63068 KB |
Output is correct |
9 |
Correct |
8 ms |
63064 KB |
Output is correct |
10 |
Correct |
10 ms |
63092 KB |
Output is correct |
11 |
Correct |
8 ms |
63020 KB |
Output is correct |
12 |
Correct |
9 ms |
63068 KB |
Output is correct |
13 |
Correct |
8 ms |
62868 KB |
Output is correct |
14 |
Correct |
7 ms |
63068 KB |
Output is correct |
15 |
Correct |
8 ms |
63068 KB |
Output is correct |
16 |
Correct |
8 ms |
63068 KB |
Output is correct |
17 |
Correct |
9 ms |
63100 KB |
Output is correct |
18 |
Correct |
8 ms |
63068 KB |
Output is correct |
19 |
Correct |
8 ms |
63068 KB |
Output is correct |
20 |
Correct |
8 ms |
63068 KB |
Output is correct |
21 |
Correct |
9 ms |
63068 KB |
Output is correct |
22 |
Correct |
7 ms |
63048 KB |
Output is correct |
23 |
Correct |
8 ms |
63068 KB |
Output is correct |
24 |
Correct |
8 ms |
63068 KB |
Output is correct |
25 |
Correct |
8 ms |
63068 KB |
Output is correct |
26 |
Correct |
8 ms |
63068 KB |
Output is correct |
27 |
Correct |
10 ms |
62884 KB |
Output is correct |
28 |
Correct |
9 ms |
63064 KB |
Output is correct |
29 |
Correct |
9 ms |
63068 KB |
Output is correct |
30 |
Correct |
9 ms |
63044 KB |
Output is correct |
31 |
Correct |
20 ms |
63396 KB |
Output is correct |
32 |
Correct |
19 ms |
63736 KB |
Output is correct |
33 |
Correct |
19 ms |
63580 KB |
Output is correct |
34 |
Correct |
20 ms |
63580 KB |
Output is correct |
35 |
Correct |
20 ms |
63580 KB |
Output is correct |
36 |
Correct |
20 ms |
63580 KB |
Output is correct |
37 |
Correct |
20 ms |
63624 KB |
Output is correct |
38 |
Correct |
19 ms |
63700 KB |
Output is correct |
39 |
Correct |
18 ms |
63580 KB |
Output is correct |
40 |
Correct |
21 ms |
63576 KB |
Output is correct |
41 |
Correct |
19 ms |
63740 KB |
Output is correct |
42 |
Correct |
19 ms |
63576 KB |
Output is correct |
43 |
Correct |
24 ms |
63836 KB |
Output is correct |
44 |
Correct |
24 ms |
63592 KB |
Output is correct |
45 |
Correct |
20 ms |
63676 KB |
Output is correct |
46 |
Correct |
37 ms |
63828 KB |
Output is correct |
47 |
Correct |
37 ms |
63832 KB |
Output is correct |
48 |
Correct |
37 ms |
63788 KB |
Output is correct |
49 |
Correct |
40 ms |
63824 KB |
Output is correct |
50 |
Correct |
37 ms |
63832 KB |
Output is correct |
51 |
Correct |
37 ms |
63700 KB |
Output is correct |
52 |
Correct |
37 ms |
63828 KB |
Output is correct |
53 |
Correct |
48 ms |
63824 KB |
Output is correct |
54 |
Correct |
48 ms |
63824 KB |
Output is correct |
55 |
Correct |
43 ms |
63836 KB |
Output is correct |
56 |
Correct |
38 ms |
63836 KB |
Output is correct |
57 |
Correct |
38 ms |
63824 KB |
Output is correct |
58 |
Correct |
37 ms |
63836 KB |
Output is correct |
59 |
Correct |
47 ms |
63896 KB |
Output is correct |
60 |
Correct |
37 ms |
63828 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
63320 KB |
Output is correct |
2 |
Correct |
9 ms |
63064 KB |
Output is correct |
3 |
Correct |
7 ms |
63068 KB |
Output is correct |
4 |
Correct |
7 ms |
62984 KB |
Output is correct |
5 |
Correct |
7 ms |
62884 KB |
Output is correct |
6 |
Correct |
8 ms |
63068 KB |
Output is correct |
7 |
Correct |
8 ms |
63052 KB |
Output is correct |
8 |
Correct |
7 ms |
63068 KB |
Output is correct |
9 |
Correct |
8 ms |
63064 KB |
Output is correct |
10 |
Correct |
10 ms |
63092 KB |
Output is correct |
11 |
Correct |
8 ms |
63020 KB |
Output is correct |
12 |
Correct |
9 ms |
63068 KB |
Output is correct |
13 |
Correct |
8 ms |
62868 KB |
Output is correct |
14 |
Correct |
7 ms |
63068 KB |
Output is correct |
15 |
Correct |
8 ms |
63068 KB |
Output is correct |
16 |
Correct |
8 ms |
63068 KB |
Output is correct |
17 |
Correct |
9 ms |
63100 KB |
Output is correct |
18 |
Correct |
8 ms |
63068 KB |
Output is correct |
19 |
Correct |
8 ms |
63068 KB |
Output is correct |
20 |
Correct |
8 ms |
63068 KB |
Output is correct |
21 |
Correct |
9 ms |
63068 KB |
Output is correct |
22 |
Correct |
7 ms |
63048 KB |
Output is correct |
23 |
Correct |
8 ms |
63068 KB |
Output is correct |
24 |
Correct |
8 ms |
63068 KB |
Output is correct |
25 |
Correct |
8 ms |
63068 KB |
Output is correct |
26 |
Correct |
8 ms |
63068 KB |
Output is correct |
27 |
Correct |
10 ms |
62884 KB |
Output is correct |
28 |
Correct |
9 ms |
63064 KB |
Output is correct |
29 |
Correct |
9 ms |
63068 KB |
Output is correct |
30 |
Correct |
9 ms |
63044 KB |
Output is correct |
31 |
Correct |
19 ms |
73704 KB |
Output is correct |
32 |
Correct |
19 ms |
73708 KB |
Output is correct |
33 |
Correct |
19 ms |
73720 KB |
Output is correct |
34 |
Correct |
20 ms |
73696 KB |
Output is correct |
35 |
Correct |
20 ms |
73696 KB |
Output is correct |
36 |
Correct |
19 ms |
73800 KB |
Output is correct |
37 |
Correct |
20 ms |
73740 KB |
Output is correct |
38 |
Correct |
23 ms |
73716 KB |
Output is correct |
39 |
Correct |
20 ms |
73768 KB |
Output is correct |
40 |
Correct |
18 ms |
73804 KB |
Output is correct |
41 |
Correct |
23 ms |
73856 KB |
Output is correct |
42 |
Correct |
20 ms |
73700 KB |
Output is correct |
43 |
Correct |
20 ms |
73744 KB |
Output is correct |
44 |
Correct |
22 ms |
73648 KB |
Output is correct |
45 |
Correct |
19 ms |
73708 KB |
Output is correct |
46 |
Correct |
20 ms |
63396 KB |
Output is correct |
47 |
Correct |
19 ms |
63736 KB |
Output is correct |
48 |
Correct |
19 ms |
63580 KB |
Output is correct |
49 |
Correct |
20 ms |
63580 KB |
Output is correct |
50 |
Correct |
20 ms |
63580 KB |
Output is correct |
51 |
Correct |
20 ms |
63580 KB |
Output is correct |
52 |
Correct |
20 ms |
63624 KB |
Output is correct |
53 |
Correct |
19 ms |
63700 KB |
Output is correct |
54 |
Correct |
18 ms |
63580 KB |
Output is correct |
55 |
Correct |
21 ms |
63576 KB |
Output is correct |
56 |
Correct |
19 ms |
63740 KB |
Output is correct |
57 |
Correct |
19 ms |
63576 KB |
Output is correct |
58 |
Correct |
24 ms |
63836 KB |
Output is correct |
59 |
Correct |
24 ms |
63592 KB |
Output is correct |
60 |
Correct |
20 ms |
63676 KB |
Output is correct |
61 |
Correct |
37 ms |
63828 KB |
Output is correct |
62 |
Correct |
37 ms |
63832 KB |
Output is correct |
63 |
Correct |
37 ms |
63788 KB |
Output is correct |
64 |
Correct |
40 ms |
63824 KB |
Output is correct |
65 |
Correct |
37 ms |
63832 KB |
Output is correct |
66 |
Correct |
37 ms |
63700 KB |
Output is correct |
67 |
Correct |
37 ms |
63828 KB |
Output is correct |
68 |
Correct |
48 ms |
63824 KB |
Output is correct |
69 |
Correct |
48 ms |
63824 KB |
Output is correct |
70 |
Correct |
43 ms |
63836 KB |
Output is correct |
71 |
Correct |
38 ms |
63836 KB |
Output is correct |
72 |
Correct |
38 ms |
63824 KB |
Output is correct |
73 |
Correct |
37 ms |
63836 KB |
Output is correct |
74 |
Correct |
47 ms |
63896 KB |
Output is correct |
75 |
Correct |
37 ms |
63828 KB |
Output is correct |
76 |
Correct |
784 ms |
82668 KB |
Output is correct |
77 |
Correct |
768 ms |
82568 KB |
Output is correct |
78 |
Correct |
786 ms |
82424 KB |
Output is correct |
79 |
Correct |
786 ms |
82688 KB |
Output is correct |
80 |
Correct |
799 ms |
82308 KB |
Output is correct |
81 |
Correct |
776 ms |
82360 KB |
Output is correct |
82 |
Correct |
799 ms |
82392 KB |
Output is correct |
83 |
Correct |
770 ms |
82408 KB |
Output is correct |
84 |
Correct |
791 ms |
82252 KB |
Output is correct |
85 |
Correct |
763 ms |
82492 KB |
Output is correct |
86 |
Correct |
766 ms |
82252 KB |
Output is correct |
87 |
Correct |
782 ms |
82240 KB |
Output is correct |
88 |
Correct |
768 ms |
82428 KB |
Output is correct |
89 |
Correct |
795 ms |
82380 KB |
Output is correct |
90 |
Correct |
793 ms |
82440 KB |
Output is correct |