# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1131617 | Hectonit | Bliskost (COI23_bliskost) | C++20 | 64 ms | 320 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
int n, q;
cin >> n >> q;
string a, b;
cin >> a >> b;
int sum = 0;
for (int i = 0; i < n; i++) {
int d = b[i] - a[i];
if ((i + 1) % 2 == n % 2) {
sum += d;
} else {
sum -= d;
}
}
if (sum == 0) {
cout << "da\n";
} else {
cout << "ne\n";
}
for (int i = 0; i < q; i++) {
char c;
int idx;
cin >> idx >> c;
int d = b[idx] - a[idx];
if ((i + 1) % 2 == n % 2) {
sum -= d;
} else {
sum += d;
}
a[idx] = c;
d = b[idx] - a[idx];
if ((i + 1) % 2 == n % 2) {
sum += d;
} else {
sum -= d;
}
if (sum == 0) {
cout << "da\n";
} else {
cout << "ne\n";
}
}
}
int main() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
}
Compilation message (stderr)
# | 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... |