Editorial for 2193: Лепрекон


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
#include <iostream>
using namespace std;
#define int long long

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin >> n >> q;
    int xornow = 0, am = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        xornow ^= a;
        am++;
    }
    while (q--) {
        int t;
        cin >> t;
        if (t == 3) {
            if (xornow == 0) {
                cout << am << "\n";
            }
            else {
                cout << 0 << "\n";
            }
        }
        else if (t == 2) {
            int x;
            cin >> x;
            xornow ^= x;
            am++;
        }
        else {
            int x;
            cin >> x;
            am--;
            xornow ^= x;
        }
    }
    return 0;
}

Коментарі

Please read the guidelines before commenting.


Ще немає коментарів.