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];
for(int i = 0;i<n;i++){
arr[i] = s2[i] - s1[i];
if(arr[i] < 0)arr[i] += 26;
}
auto get = [&]{
int tmp[n] = {0};
for(int i = 0;i<n-1;i++){
while(arr[i] != tmp[i]){
tmp[i] = (tmp[i] + 1) % 26;
tmp[i+1] = (tmp[i+1] + 1) % 26;
}
}
if(arr[n-1] == tmp[n-1])return "da";
else return "ne";
};
cout << get() << endl;
while(q--){
int pos;
char ch;
cin >> pos >> ch;
pos--;
s1[pos] = ch;
arr[pos] = s2[pos] - s1[pos];
if(arr[pos] < 0)arr[pos] += 26;
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... |