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 pb push_back
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
const int INF = 2147483645;
const int maxN = (int)1e3+5;
const ll LLINF = LLONG_MAX;
//const ll mod = 998244353;
const ll mod = 1000000007;
void solv() {
int n, q;
cin>>n>>q;
string a, b, ta;
cin>>a>>b;
int carry = 0;
int x;
char z;
for (int i=0;i<n;i++) a[i] -= 'a', b[i] -= 'a';
for (int i=0;i<=q;i++) {
if (i) {
cin>>x>>z;
carry = 0;
a[x-1] = z-'a';
}
ta = a;
for (int j=n-1;j>=0;j--) {
ta[j] = (ta[j] + carry)%26;
if (ta[j] > b[j]) carry = 26-ta[j]+b[j];
else carry = b[j]-ta[j];
}
if (ta[0] == b[0]) cout<<"da\n";
else cout<<"ne\n";
}
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int t=1;
// cin>>t;
while (t--) solv();
}
# | 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... |