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 debug(x) {cout << #x << ": "; for (auto it : x) cout << it << " ";cout << endl;}
#define fast ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
#define f first
#define s second
#define MOD 1000000007
#define LOGN 15
#define MAXN 100005
 
vector<int> diff;
int main() {
	fast
	int N, Q;
	string S, T;
	cin >> N >> Q >> S >> T;
	S = "#" + S;
	T = "#" + T;
	diff = vector<int>(N+1);
	int even = 0, odd = 0;
	for (int i = 1; i <= N; i++) {
		diff[i] = (T[i] - S[i] + 26) % 26;
		if (i % 2)
			odd += diff[i];
		else
			even += diff[i];
	}
	if (even % 26 == odd % 26)
		cout << "da\n";
	else
		cout << "ne\n"; 
 	while (Q--) {
 		int plc; char ch;
 		cin >> plc >> ch;
 		int last = diff[plc];
 		S[plc] = ch;
 		diff[plc] = (T[plc] - ch + 26) % 26;
 		if (plc % 2) {
 			odd += diff[plc] - last;
 			if (odd < 0)
 				odd += 26; 
 		} else {
 			even += diff[plc] - last;
 			if (even < 0)
 				even += 26;
 		}
 		if (even % 26 == odd % 26)
 			cout << "da\n";
 		else
 			cout << "ne\n"; 
 	}
}
| # | 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... |