Submission #1128960

#TimeUsernameProblemLanguageResultExecution timeMemory
1128960ivazivaBliskost (COI23_bliskost)C++20
57 / 100
1095 ms13180 KiB
#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; for (int i=1;i<=n;i++) { y[i]=s2[i-1]-s1[i-1]; if (y[i]<0) y[i]+='z'-'a'+1; } x[1]=y[1]; for (int i=2;i<n;i++) { x[i]=y[i]-x[i-1]; if (x[i]<0) x[i]+='z'-'a'+1; } 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]; if (y[n]<0) y[n]+='z'-'a'+1; if (x[n-1]==y[n]) cout<<"da"<<endl; else cout<<"ne"<<endl; continue; } int val=s1[pos-1]-c;s1[pos-1]=c; if (val<0) val+='z'-'a'+1; if ((n-1)%2==pos%2) 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...