Submission #1212140

#TimeUsernameProblemLanguageResultExecution timeMemory
1212140rhm_ganBliskost (COI23_bliskost)C++20
100 / 100
104 ms9824 KiB
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 42
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, q;
    cin >> n >> q;

    string a, b;
    cin >> a >> b;

    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        d[i] = b[i] - a[i];
    }

    int even = 0, odd = 0;
    for (int i = 0; i < n; i++) {
        if (i & 1) odd += d[i];
        else even += d[i];
    }

    even = ((even % 26) + 26) % 26;
    odd = ((odd % 26) + 26) % 26;

    cout << (even == odd ? "da" : "ne") << '\n';

    while (q--) {
        int i;
        char c;
        cin >> i >> c;
        i--;
        if (i & 1) {
            odd -= b[i] - a[i];
            a[i] = c;
            odd += b[i] - a[i];
            odd = ((odd % 26) + 26) % 26;
        }
        else {
            even -= b[i] - a[i];
            a[i] = c;
            even += b[i] - a[i];
            even = ((even % 26) + 26) % 26;
        }
        cout << (even == odd ? "da" : "ne") << '\n';
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...