Submission #490808

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

const int N = 4e5 + 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 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 224 KB Output is correct
5 Correct 1 ms 204 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 2 ms 332 KB Output is correct
4 Correct 1 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 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 224 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 10 ms 588 KB Output is correct
12 Correct 7 ms 612 KB Output is correct
13 Correct 13 ms 652 KB Output is correct
14 Correct 10 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 460 ms 10024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 224 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 10 ms 588 KB Output is correct
12 Correct 7 ms 612 KB Output is correct
13 Correct 13 ms 652 KB Output is correct
14 Correct 10 ms 580 KB Output is correct
15 Incorrect 460 ms 10024 KB Output isn't correct
16 Halted 0 ms 0 KB -