답안 #1097843

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097843 2024-10-08T10:27:20 Z SulA XORanges (eJOI19_xoranges) C++17
100 / 100
86 ms 10584 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define bitcount __builtin_popcountll
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<long long,null_type,less_equal<>,rb_tree_tag,tree_order_statistics_node_update>;

struct segtree {
    vector<int> tree;
    int offset = 1;

    segtree(int n) {
        while (offset < n) offset <<= 1;
        tree.resize(offset << 1, 0);
    }

    void update(int i, int x) {
        tree[i += offset] = x;
        while (i >>= 1) tree[i] = tree[2*i] ^ tree[2*i + 1];
    }

    int _query(int v, int l, int r, int ql, int qr) {
        if (ql <= l && r <= qr) return tree[v];
        if (qr < l || r < ql) return 0;
        int mid = (l+r)/2;
        return
        _query(2*v, l, mid, ql, qr) ^
        _query(2*v+1, mid+1, r, ql, qr);
    }

    int query(int l, int r) { return _query(1, 0, offset - 1, l, r); }
};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int n,q; cin >> n >> q;
    segtree s[2] = {n, n};
    for (int i = 0; i < n; i++) {
        int ai; cin >> ai;
        s[i & 1].update(i, ai);
    }
    while (q--) {
        int t; cin >> t;
        if (t == 1) {
            int i,x; cin >> i >> x;
            i--;
            s[i & 1].update(i, x);
        } else {
            int l,r; cin >> l >> r;
            l--, r--;
            if ((r-l+1) & 1) cout << s[l & 1].query(l, r);
            else cout << 0;
            cout << '\n';
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 692 KB Output is correct
12 Correct 2 ms 636 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 10584 KB Output is correct
2 Correct 85 ms 10396 KB Output is correct
3 Correct 84 ms 10408 KB Output is correct
4 Correct 78 ms 10060 KB Output is correct
5 Correct 80 ms 10060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 692 KB Output is correct
12 Correct 2 ms 636 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 85 ms 10584 KB Output is correct
16 Correct 85 ms 10396 KB Output is correct
17 Correct 84 ms 10408 KB Output is correct
18 Correct 78 ms 10060 KB Output is correct
19 Correct 80 ms 10060 KB Output is correct
20 Correct 75 ms 10320 KB Output is correct
21 Correct 78 ms 10184 KB Output is correct
22 Correct 74 ms 10324 KB Output is correct
23 Correct 78 ms 10168 KB Output is correct
24 Correct 86 ms 10068 KB Output is correct