제출 #1128959

#제출 시각아이디문제언어결과실행 시간메모리
1128959ivazivaBliskost (COI23_bliskost)C++20
57 / 100
1096 ms12488 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 1000001 int n,q; string s1,s2; int x[MAXN],y[MAXN]; int main() { 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...