Submission #467885

# Submission time Handle Problem Language Result Execution time Memory
467885 2021-08-25T13:00:03 Z alontanay XORanges (eJOI19_xoranges) C++14
100 / 100
670 ms 25140 KB
#include <bits/stdc++.h>

using namespace std;

struct Seg {
    int val = 0;
    int l,r,mid;
    Seg *ls, *rs;
    Seg(int l, int r): l(l), r(r), mid((l+r)/2) {
        if(l + 1 < r) {
            ls = new Seg(l, mid);
            rs = new Seg(mid, r);
        }
    }
    int query(int a, int b) {
        if(a >= r || b <= l) { return 0; }
        if(a <= l && b >= r) { return val; }
        return (ls->query(a,b))^(rs->query(a,b));
    }
    void update(int i, int x) {
        if(l + 1 == r) {
            val = x;
            return;
        }
        if(i < mid) { ls->update(i,x); } else { rs->update(i,x); }
        val = (ls->val)^(rs->val);
    }
};

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

    int n,q,x,y,t;
    cin >> n >> q;
    Seg odd(0, (int)((n+1)/2));
    Seg even(0, n/2);
    for(int i = 0; i < n / 2; i ++) {
        cin >> x;
        odd.update(i, x);
        cin >> x;
        even.update(i, x);
    }
    if(n%2) {
        cin >> x;
        odd.update((n-1)/2, x);
    }
    for(int i = 0; i < q; i ++) {
        cin >> t >> x >> y; x--;
        if(t == 1) {
            if(x%2) {
                even.update(x/2, y);
            } else {
                odd.update(x/2, y);
            }
        } else {
            if((y - x)%2) {
                if(x%2) {
                    cout << even.query(x/2,(y+1)/2) << endl;
                } else {
                    cout << odd.query(x/2,(y+1)/2) << endl;
                }
            } else {
                cout << 0 << endl;
            }
        }
    }
    return 0;
}
# 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 204 KB Output is correct
4 Correct 1 ms 204 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 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 204 KB Output is correct
4 Correct 1 ms 204 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 2 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 8 ms 844 KB Output is correct
12 Correct 11 ms 916 KB Output is correct
13 Correct 14 ms 900 KB Output is correct
14 Correct 12 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 571 ms 25084 KB Output is correct
2 Correct 593 ms 25140 KB Output is correct
3 Correct 670 ms 25076 KB Output is correct
4 Correct 486 ms 24768 KB Output is correct
5 Correct 527 ms 24704 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 204 KB Output is correct
4 Correct 1 ms 204 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 2 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 8 ms 844 KB Output is correct
12 Correct 11 ms 916 KB Output is correct
13 Correct 14 ms 900 KB Output is correct
14 Correct 12 ms 896 KB Output is correct
15 Correct 571 ms 25084 KB Output is correct
16 Correct 593 ms 25140 KB Output is correct
17 Correct 670 ms 25076 KB Output is correct
18 Correct 486 ms 24768 KB Output is correct
19 Correct 527 ms 24704 KB Output is correct
20 Correct 422 ms 24852 KB Output is correct
21 Correct 534 ms 24740 KB Output is correct
22 Correct 410 ms 24848 KB Output is correct
23 Correct 519 ms 24832 KB Output is correct
24 Correct 474 ms 24672 KB Output is correct