#include <bits/stdc++.h>
using namespace std;
#define int long long
#define arr array
const int N = 1e6 + 6;
int n, q;
arr<int, N> a, b;
int md(int x) { return (x + 26) % 26; }
int fnl;
void prcmp() {
for (int i = 1; i <= n; i++)
fnl = (i % 2 == n % 2) ? md(fnl + a[i]) : md(fnl - a[i]);
for (int i = 1; i < n; i++)
fnl = (i % 2 == n % 2) ? md(fnl - b[i]) : md(fnl + b[i]);
}
void prnt() {
// cout << fnl << endl;
cout << ((fnl == b[n]) ? "da" : "ne") << '\n';
}
void cmp() {
prnt();
for (int i = 1; i <= q; i++) {
int j; char x; cin >> j >> x;
int y = x - 'a';
int df = md(y - a[j]);
a[j] = y;
fnl = (j % 2 == n % 2) ? md(fnl + df) : md(fnl - df);
prnt();
}
}
signed main() {
// freopen("a.in", "r", stdin);
cin >> n >> q;
for (int i = 1; i <= n; i++) {
char x; cin >> x;
a[i] = x - 'a';
}
for (int i = 1; i <= n; i++) {
char x; cin >> x;
b[i] = x - 'a';
}
prcmp();
cmp();
}
# | 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... |