#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("tune=native")
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1000001
int n,q;
string s1,s2;
int x[MAXN],y[MAXN];
int main()
{
ios_base::sync_with_stdio(false);
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n>>q;cin>>s1>>s2;
y[1]=s2[0]-s1[0];
if (y[1]<0) y[1]+=26;
x[1]=y[1];
for (int i=2;i<=n;i++)
{
y[i]=(s2[i-1]-s1[i-1]+26)%26;
x[i]=(y[i]-x[i-1]+26)%26;
}
if (x[n-1]==y[n]) cout<<"da"<<endl;
else cout<<"ne"<<endl;
for (int z=0;z<q;z++)
{
int pos;cin>>pos;char c;cin>>c;
if (pos==n)
{
s1[n-1]=c;y[n]=(s2[n-1]-s1[n-1]+26)%26;
if (x[n-1]==y[n]) cout<<"da"<<endl;
else cout<<"ne"<<endl;
continue;
}
int val=(s1[pos-1]-c+26)%26;s1[pos-1]=c;
if ((n-1-pos)%2==0) x[n-1]+=val;
else x[n-1]-=val;
if (x[n-1]>=26) x[n-1]-=26;
else if (x[n-1]<0) x[n-1]+=26;
if (x[n-1]==y[n]) cout<<"da"<<endl;
else cout<<"ne"<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |