Submission #490805

# Submission time Handle Problem Language Result Execution time Memory
490805 2021-11-29T10:20:17 Z vulpes XORanges (eJOI19_xoranges) C++17
55 / 100
27 ms 4928 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 7;
int a[N], t[N][2];

void build(int v, int l, int r) {
    if (l == r) {
        t[v][0] = (1 - l % 2) * a[l];
        t[v][1] = (l % 2) * a[l];
        return;
    }
    int m = (l + r) / 2;
    build(2 * v, l, m);
    build(2 * v + 1, m + 1, r);
    t[v][0] = t[2 * v][0] ^ t[2 * v + 1][0];
    t[v][1] = t[2 * v][1] ^ t[2 * v + 1][1];
}

void upd(int v, int l, int r, int x) {
    if (x > r || x < l) {
        return;
    }
    if (l == r) {
        t[v][0] = (1 - l % 2) * a[l];
        t[v][1] = (l % 2) * a[l];
        return;
    }
    int m = (l + r) / 2;
    upd(2 * v, l, m, x);
    upd(2 * v + 1, m + 1, r, x);
    t[v][0] = t[2 * v][0] ^ t[2 * v + 1][0];
    t[v][1] = t[2 * v][1] ^ t[2 * v + 1][1];
}

int calc(int v, int l, int r, int L, int R) {
    if (L > r || l > R) {
        return 0;
    }
    if (L <= l && r <= R) {
        return t[v][L % 2];
    }
    int m = (l + r) / 2;
    return calc(2 * v, l, m, L, R) ^
           calc(2 * v + 1, m + 1, r, L, R);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, q; cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    build(1, 1, n);
    while (q--) {
        int x, y, z; cin >> x >> y >> z;
        if (x == 1) {
            a[y] = z; upd(1, 1, n, y);
            continue;
        }
        int f = (z - y + 1) % 2;
        cout << f * calc(1, 1, n, y, z) << endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 3 ms 328 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 3 ms 328 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 7 ms 608 KB Output is correct
12 Correct 6 ms 588 KB Output is correct
13 Correct 14 ms 588 KB Output is correct
14 Correct 9 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 4928 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 3 ms 328 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 7 ms 608 KB Output is correct
12 Correct 6 ms 588 KB Output is correct
13 Correct 14 ms 588 KB Output is correct
14 Correct 9 ms 588 KB Output is correct
15 Runtime error 27 ms 4928 KB Execution killed with signal 11
16 Halted 0 ms 0 KB -