답안 #972601

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972601 2024-04-30T17:33:14 Z njoop XORanges (eJOI19_xoranges) C++14
100 / 100
132 ms 10832 KB
#include <bits/stdc++.h>

using namespace std;

int n, q, od[600010], ev[600010], c, id, va, in, st, en, f, s, enu, onu;

void update(int l, int r, int idx, int val, int node, int (&seg)[600010]) {
    if(l == r) {
        seg[node] = val;
        return;
    }
    int mid = (l+r)>>1;
    if(idx <= mid) update(l, mid, idx, val, node*2, seg);
    else update(mid+1, r, idx, val, node*2+1, seg);
    seg[node] = seg[node*2]^seg[node*2+1];
}

int query(int l, int r, int ql, int qr, int node, int (&seg)[600010]) {
    if(l > qr || r < ql) return 0;
    if(l >= ql && r <= qr) return seg[node];
    int mid = (l+r)>>1;
    return query(l, mid, ql, qr, node*2, seg)^query(mid+1, r, ql, qr, node*2+1, seg);
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> q;
    for(int i=1; i<=n; i++) {
        cin >> in;
        if(i%2) {
            update(1, n, i, in, 1, od);
        } else {
            update(1, n, i, in, 1, ev);
        }
    }
    while(q--) {
        cin >> c;
        if(c == 1) {
            cin >> id >> va;
            if(id%2 == 0) update(1, n, id, va, 1, ev);
            else update(1, n, id, va, 1, od);
        } else {
            cin >> st >> en;
            if((en-st)%2) cout << 0 << "\n";
            else if(st%2) {
                cout << query(1, n, st, en, 1, od) << "\n";
            } else {
                cout << query(1, n, st, en, 1, ev) << "\n";
            }
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2404 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 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 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
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2404 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 2392 KB Output is correct
11 Correct 3 ms 2392 KB Output is correct
12 Correct 3 ms 2648 KB Output is correct
13 Correct 3 ms 2396 KB Output is correct
14 Correct 3 ms 2576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 132 ms 9788 KB Output is correct
2 Correct 113 ms 10680 KB Output is correct
3 Correct 113 ms 10636 KB Output is correct
4 Correct 106 ms 10832 KB Output is correct
5 Correct 105 ms 10412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 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
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2404 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 2392 KB Output is correct
11 Correct 3 ms 2392 KB Output is correct
12 Correct 3 ms 2648 KB Output is correct
13 Correct 3 ms 2396 KB Output is correct
14 Correct 3 ms 2576 KB Output is correct
15 Correct 132 ms 9788 KB Output is correct
16 Correct 113 ms 10680 KB Output is correct
17 Correct 113 ms 10636 KB Output is correct
18 Correct 106 ms 10832 KB Output is correct
19 Correct 105 ms 10412 KB Output is correct
20 Correct 107 ms 10584 KB Output is correct
21 Correct 105 ms 10384 KB Output is correct
22 Correct 114 ms 10648 KB Output is correct
23 Correct 105 ms 10400 KB Output is correct
24 Correct 103 ms 10328 KB Output is correct