답안 #972214

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972214 2024-04-30T08:46:58 Z jadai007 XORanges (eJOI19_xoranges) C++17
100 / 100
112 ms 7952 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 (r - l + 1)&1 ? cout << tree[l&1].query(1, n, l, r, 1) << '\n' : cout << 0 << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2532 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 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 2392 KB Output is correct
7 Correct 1 ms 2532 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 3 ms 2396 KB Output is correct
12 Correct 2 ms 2396 KB Output is correct
13 Correct 3 ms 2396 KB Output is correct
14 Correct 3 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 107 ms 7760 KB Output is correct
2 Correct 112 ms 7936 KB Output is correct
3 Correct 100 ms 7768 KB Output is correct
4 Correct 91 ms 7764 KB Output is correct
5 Correct 91 ms 7952 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 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 2392 KB Output is correct
7 Correct 1 ms 2532 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 3 ms 2396 KB Output is correct
12 Correct 2 ms 2396 KB Output is correct
13 Correct 3 ms 2396 KB Output is correct
14 Correct 3 ms 2396 KB Output is correct
15 Correct 107 ms 7760 KB Output is correct
16 Correct 112 ms 7936 KB Output is correct
17 Correct 100 ms 7768 KB Output is correct
18 Correct 91 ms 7764 KB Output is correct
19 Correct 91 ms 7952 KB Output is correct
20 Correct 102 ms 7324 KB Output is correct
21 Correct 95 ms 7372 KB Output is correct
22 Correct 92 ms 7256 KB Output is correct
23 Correct 90 ms 7760 KB Output is correct
24 Correct 91 ms 7908 KB Output is correct