#pragma GCC optimize("Ofast")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-finline")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-fno-stack-protector")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-funroll-loops")
#pragma GCC target("abm")
#pragma GCC target("avx")
#pragma GCC target("mmx")
#pragma GCC target("popcnt")
#pragma GCC target("sse")
#pragma GCC target("sse2")
#pragma GCC target("sse3")
#pragma GCC target("sse4")
#pragma GCC target("ssse3")
#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... |