Submission #1026776

#TimeUsernameProblemLanguageResultExecution timeMemory
1026776vjudge1Bliskost (COI23_bliskost)C++17
28 / 100
50 ms3832 KiB
#include<bits/stdc++.h> using namespace std; #define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define ll long long #define int long long int #define endl '\n' #define N 150100 #define M 15 #define big 2147483647 #define bigg 9223372036854775807 #define pb push_back #define p push #define ins insert #define f first int farr(char a,char b){ //(a->b yol) if(a==b)return 0; if((int)a<(int)b) return ((int)b-(int)a); return (int)b-'a'+(int)('z'-a)+1; } int indir(int x,int y){ while(y--){ if(x==0)x=M-1; else x--; } return x; } signed main(){ lalala; int n,q;cin>>n>>q; string str,hedef;cin>>str>>hedef; string yedek=str; for(int i=0;i<(int)yedek.size()-1;i++){ while(yedek[i]!=hedef[i]){ if(yedek[i]=='z')yedek[i]='a'; else yedek[i]++; if(yedek[i+1]=='z')yedek[i+1]='a'; else yedek[i+1]++; } } if(yedek[n-1]!=hedef[n-1])cout<<"ne"<<endl; else cout<<"da"<<endl; int son=yedek[n-1]-'a',hedefim=hedef[n-1]-'a'; while(q--){ int x;char a;cin>>x>>a; x--; int fark1=farr(str[x],hedef[x]), fark2=farr(a,hedef[x]); str[x]=a; int fark; if(fark1>=fark2){ fark=fark1-fark2; if(((x+1)%2)==(n%2))son=(son+fark)%M; else son=indir(son,fark); } else{ fark=fark2-fark1; if(((x+1)%2)==(n%2))son=indir(son,fark); else son=(son+fark)%M; } //cout<<son<<" "<<fark1<<" "<<fark2<<" "<<fark<<endl; if(son==hedefim) 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...