Submission #838485

# Submission time Handle Problem Language Result Execution time Memory
838485 2023-08-27T08:49:26 Z BlockOG XORanges (eJOI19_xoranges) C++14
100 / 100
261 ms 4316 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 n, int i, unsigned int c) {
    i++; while (i <= n) {
        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, n, 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, n, 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 212 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 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 212 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
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 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 4 ms 468 KB Output is correct
12 Correct 5 ms 468 KB Output is correct
13 Correct 6 ms 468 KB Output is correct
14 Correct 7 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 258 ms 4088 KB Output is correct
2 Correct 255 ms 4044 KB Output is correct
3 Correct 261 ms 4112 KB Output is correct
4 Correct 257 ms 4316 KB Output is correct
5 Correct 250 ms 4068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 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
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 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 4 ms 468 KB Output is correct
12 Correct 5 ms 468 KB Output is correct
13 Correct 6 ms 468 KB Output is correct
14 Correct 7 ms 468 KB Output is correct
15 Correct 258 ms 4088 KB Output is correct
16 Correct 255 ms 4044 KB Output is correct
17 Correct 261 ms 4112 KB Output is correct
18 Correct 257 ms 4316 KB Output is correct
19 Correct 250 ms 4068 KB Output is correct
20 Correct 164 ms 3408 KB Output is correct
21 Correct 169 ms 3388 KB Output is correct
22 Correct 161 ms 3404 KB Output is correct
23 Correct 241 ms 3992 KB Output is correct
24 Correct 243 ms 4044 KB Output is correct