제출 #1128962

#제출 시각아이디문제언어결과실행 시간메모리
1128962ivazivaBliskost (COI23_bliskost)C++20
57 / 100
1096 ms13208 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]+=26; } x[1]=y[1]; for (int i=2;i<n;i++) { x[i]=y[i]-x[i-1]; if (x[i]<0) x[i]+=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]; if (y[n]<0) y[n]+=26; 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+=26; 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 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...