This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// HELLLLLLLNAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define ins insert
#define pb push_back
#define endl '\n'
#define putr(x) cout<<x<<endl;return;
#define all(x) x.begin(),x.end()
const int mod = 1e9 +7, sze = 1e5 +5, inf = INT_MAX, LL = 30;
void rush(){
int n,q;
cin>>n>>q;
string s,t;
cin>>s>>t;
vector<int> pref(n,0);
for(int i=0;i<n;i++){
pref[i]=(t[i]-s[i] + 26)%26;
if(i){
pref[i]=(-pref[i-1] + pref[i] + 26)%26;
}
}
if(pref.back()==0){
cout<<"da\n";
}
else{
cout<<"ne\n";
}
int tot = 0;
while(q--){
int idx;
cin>>idx;
char c;
cin>>c;
--idx;
int diff = c - s[idx];
cout<<diff<<endl;
s[idx]=c;
if((n-idx)&1){
pref.back()=(pref.back() + 26 - diff)%26;
}
else{
pref.back()=(pref.back() + diff)%26;
}
if(pref.back()==0){
cout<<"da\n";
}
else{
cout<<"ne\n";
}
}
/*
amelelik :
ab | bb
pref: 1 25
2 a , -1, b->b, b->a->b
perf : 1 0
ferq tek olanda, last positiona tesir elemir
1 b : 1, aa -. ba
pref : 0,1
*/
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int tt = 1;
// cin>>tt;
while(tt--){
rush();
}
return 0;
}
Compilation message (stderr)
Main.cpp: In function 'void rush()':
Main.cpp:30:9: warning: unused variable 'tot' [-Wunused-variable]
30 | int tot = 0;
| ^~~
# | 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... |