Submission #838480

# Submission time Handle Problem Language Result Execution time Memory
838480 2023-08-27T07:43:48 Z BlockOG XORanges (eJOI19_xoranges) C++14
100 / 100
271 ms 8416 KB
#include <iostream>

using namespace std;

unsigned int o[200000], b1[200001], b2[200001];

unsigned int bxor(unsigned int b[200001], int i) {
    i++; unsigned int res = 0;
    while (i > 0) {
        res ^= b[i];
        i -= i & (-i);
    }
    return res;
}

void bchg(unsigned int b[200001], int i, unsigned int c) {
    i++; while (i <= 200000) {
        b[i] ^= c;
        i += i & (-i);
    }
}

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

    int n, q; cin >> n >> q;
    for (int i = 0; i < n; i++) {
        cin >> o[i];
        bchg(i & 1 ? b2 : b1, i, o[i]);
    }

    for (int it = 0; it < q; it++) {
        int code; cin >> code;
        if (code == 1) {
            int i; unsigned int j; cin >> i >> j; i--;
            bchg(i & 1 ? b2 : b1, i, j ^ o[i]);
            o[i] = j;
        } else {
            int l, u; cin >> l >> u;
            if (!((u - l + 1) & 1)) {
                cout << 0 << endl;
                continue;
            }

            cout << (bxor(l & 1 ? b1 : b2, l - 2) ^ bxor(l & 1 ? b1 : b2, u - 1)) << endl;
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 5 ms 468 KB Output is correct
12 Correct 5 ms 464 KB Output is correct
13 Correct 7 ms 464 KB Output is correct
14 Correct 7 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 265 ms 7984 KB Output is correct
2 Correct 271 ms 4184 KB Output is correct
3 Correct 256 ms 4168 KB Output is correct
4 Correct 254 ms 5568 KB Output is correct
5 Correct 255 ms 8372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 5 ms 468 KB Output is correct
12 Correct 5 ms 464 KB Output is correct
13 Correct 7 ms 464 KB Output is correct
14 Correct 7 ms 468 KB Output is correct
15 Correct 265 ms 7984 KB Output is correct
16 Correct 271 ms 4184 KB Output is correct
17 Correct 256 ms 4168 KB Output is correct
18 Correct 254 ms 5568 KB Output is correct
19 Correct 255 ms 8372 KB Output is correct
20 Correct 163 ms 8408 KB Output is correct
21 Correct 160 ms 8332 KB Output is correct
22 Correct 202 ms 8416 KB Output is correct
23 Correct 245 ms 8348 KB Output is correct
24 Correct 244 ms 8412 KB Output is correct