This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PB push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F first
#define S second
#define PB push_back
// void setIO(string s) {
// freopen((s + ".in").c_str(), "r", stdin);
// freopen((s + ".out").c_str(), "w", stdout);
// }
void solve(){
int n, q; cin >> n >> q;
string a, b; cin >> a >> b;
string x = a, y = b;
for(int i = n-1; i > 0; i--){
if(a[i] <= b[i]){
int d = b[i]-a[i];
a[i] = b[i];
a[i-1] = char( ((a[i-1]-'a'+d)%26) + 'a');
}else{
int d = a[i]-b[i];
b[i] = a[i];
b[i-1] = char( ((b[i-1]-'a'+d)%26) + 'a');
}
}
int best = b[0]-a[0];
cout << (!best?"da":"ne") << '\n';
a = x, b = y;
best = b[0]-a[0];
for(int i = 0; i < q; i++){
int p; cin >> p;
p--;
char c; cin >> c;
best += c-a[p];
best %= 26;
a[p]=c;
cout << (!best?"da":"ne") << '\n';
}
}
int main(){
ios_base::sync_with_stdio(false), cout.tie(NULL), cin.tie(NULL);
// setIO("");
int testcase = 1;
// cin >> testcase;
for(int i = 1; i <= testcase; i++){
// cout << "Case " << i << ": ";
solve();
}
}
# | 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... |