Submission #972216

# Submission time Handle Problem Language Result Execution time Memory
972216 2024-04-30T08:48:09 Z jadai007 XORanges (eJOI19_xoranges) C++17
100 / 100
107 ms 7912 KB
#include<bits/stdc++.h>

using namespace std;

struct SegmentTree{
    int seg[1000100] = {0};
    void update(int l, int r, int idx, int val, int node){
        if(l == r){
            seg[node] = val;
            return;
        }
        int mid = (l + r) >> 1;
        if(idx <= mid) update(l, mid, idx, val, node*2);
        else update(mid+1, r, idx,val, node*2+1);
        seg[node] = seg[node*2]^seg[node*2+1];
    }
    int query(int l, int r, int ql, int qr, int node){
        if(r < ql || l > qr) return 0;
        if(l >= ql && r <= qr) return seg[node];

        int mid = (l + r) >> 1;
        return query(l, mid, ql, qr, node*2)^query(mid+1, r, ql, qr, node*2+1);
    }
}tree[2];

int n, q, a;

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n >> q;
    for(int i = 1; i<=n; ++i) cin >> a, tree[i&1].update(1, n, i, a, 1);
    while(q--){
        int t, l, r; cin >> t >> l >> r;
        if(t == 1) tree[l&1].update(1, n, l, r, 1);
        else (r - l + 1)&1 ? cout << tree[l&1].query(1, n, l, r, 1) << '\n' : cout << 0 << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 2 ms 2396 KB Output is correct
12 Correct 3 ms 2396 KB Output is correct
13 Correct 2 ms 2592 KB Output is correct
14 Correct 2 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 99 ms 7840 KB Output is correct
2 Correct 107 ms 7848 KB Output is correct
3 Correct 107 ms 7844 KB Output is correct
4 Correct 93 ms 7764 KB Output is correct
5 Correct 89 ms 7764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 2 ms 2396 KB Output is correct
12 Correct 3 ms 2396 KB Output is correct
13 Correct 2 ms 2592 KB Output is correct
14 Correct 2 ms 2392 KB Output is correct
15 Correct 99 ms 7840 KB Output is correct
16 Correct 107 ms 7848 KB Output is correct
17 Correct 107 ms 7844 KB Output is correct
18 Correct 93 ms 7764 KB Output is correct
19 Correct 89 ms 7764 KB Output is correct
20 Correct 95 ms 7324 KB Output is correct
21 Correct 105 ms 7720 KB Output is correct
22 Correct 91 ms 7280 KB Output is correct
23 Correct 89 ms 7720 KB Output is correct
24 Correct 90 ms 7912 KB Output is correct