답안 #972206

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972206 2024-04-30T08:40:43 Z vjudge1 XORanges (eJOI19_xoranges) C++17
100 / 100
107 ms 12728 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);
    }
};

SegmentTree 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{
            if((r - l + 1)%2 == 0) cout << 0 << '\n';
            else cout << tree[l&1].query(1, n, l, r, 1) << '\n';
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2532 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 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 2532 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 3 ms 2652 KB Output is correct
12 Correct 3 ms 2524 KB Output is correct
13 Correct 3 ms 2660 KB Output is correct
14 Correct 3 ms 2556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 7832 KB Output is correct
2 Correct 101 ms 12656 KB Output is correct
3 Correct 103 ms 12728 KB Output is correct
4 Correct 106 ms 12248 KB Output is correct
5 Correct 93 ms 12372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 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 2532 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 3 ms 2652 KB Output is correct
12 Correct 3 ms 2524 KB Output is correct
13 Correct 3 ms 2660 KB Output is correct
14 Correct 3 ms 2556 KB Output is correct
15 Correct 98 ms 7832 KB Output is correct
16 Correct 101 ms 12656 KB Output is correct
17 Correct 103 ms 12728 KB Output is correct
18 Correct 106 ms 12248 KB Output is correct
19 Correct 93 ms 12372 KB Output is correct
20 Correct 107 ms 12352 KB Output is correct
21 Correct 96 ms 12568 KB Output is correct
22 Correct 94 ms 12372 KB Output is correct
23 Correct 91 ms 12368 KB Output is correct
24 Correct 97 ms 12368 KB Output is correct