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;
const int K = 26;
struct SegTree
{
int l, r, mid;
SegTree *lc, *rc;
int val;
SegTree(const vector<int> &a, int l_, int r_) : l(l_), r(r_)
{
mid = (l + r) / 2;
if (l == r - 1)
{
val = a[l];
return;
}
lc = new SegTree(a, l, mid);
rc = new SegTree(a, mid, r);
pull();
}
void pull()
{
val = (rc->val + ((r - mid) % 2 == 0 ? 1 : -1) * lc->val + K) % K;
}
void update(int i, int u)
{
if (l == r - 1)
{
val = u;
return;
}
if (i < mid)
{
lc->update(i, u);
}
else
{
rc->update(i, u);
}
pull();
}
};
int main()
{
cin.tie(0)->sync_with_stdio(0);
int n, q;
cin >> n >> q;
string a, b;
cin >> a >> b;
vector<int> c(n);
for (int i = 0; i < n; i++)
{
c[i] = (b[i] - a[i] + K) % K;
}
SegTree st(c, 0, n);
cout << (st.val == 0 ? "da" : "ne") << '\n';
while (q--)
{
int j;
char x;
cin >> j >> x;
j--;
a[j] = x;
st.update(j, (b[j] - a[j] + K) % K);
cout << (st.val == 0 ? "da" : "ne") << '\n';
}
return 0;
}
# | 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... |