This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Author : FatihCihan
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
void solve(){
int n,q;
cin >> n >> q;
string s1 , s2;
cin >> s1 >> s2;
int arr[n] , sum[2] = {0,0};
for(int i = 0;i<n;i++){
arr[i] = s2[i] - s1[i];
if(arr[i] < 0)arr[i] += 26;
if(i < (n-1))sum[i & 1] += arr[i];
}
// cout << "arr : ";for(int i = 0;i<n;i++)cout << arr[i] << " ";cout << endl;
auto get = [&]{
int value = ((sum[n&1] - sum[(n&1)^1]) % 26 + 26) % 26;
if(value == arr[n-1])return "da";
else return "ne";
};
cout << get() << endl;
while(q--){
int pos;
char ch;
cin >> pos >> ch;
pos--;
if(pos < (n-1))sum[pos&1] -= arr[pos];
s1[pos] = ch;
arr[pos] = s2[pos] - s1[pos];
if(arr[pos] < 0)arr[pos] += 26;
if(pos < (n-1))sum[pos&1] += arr[pos];
cout << get() << endl;
}
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int testcase = 1;//cin >> testcase;
while(testcase--)solve();
cerr << 1000.0 * clock() / CLOCKS_PER_SEC << " ms" << endl;
}
# | 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... |