답안 #972599

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

using namespace std;

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

void update(int l, int r, int idx, int val, int node, int (&seg)[400010]) {
    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)[400010]) {
    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 2516 KB Output is correct
2 Correct 1 ms 2520 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 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 2516 KB Output is correct
7 Correct 1 ms 2520 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 4 ms 2652 KB Output is correct
12 Correct 3 ms 2652 KB Output is correct
13 Correct 3 ms 2652 KB Output is correct
14 Correct 3 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 23 ms 7812 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 2516 KB Output is correct
7 Correct 1 ms 2520 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 4 ms 2652 KB Output is correct
12 Correct 3 ms 2652 KB Output is correct
13 Correct 3 ms 2652 KB Output is correct
14 Correct 3 ms 2652 KB Output is correct
15 Runtime error 23 ms 7812 KB Execution killed with signal 11
16 Halted 0 ms 0 KB -