Submission #464343

# Submission time Handle Problem Language Result Execution time Memory
464343 2021-08-13T04:05:52 Z tengiz05 XORanges (eJOI19_xoranges) C++17
0 / 100
157 ms 6152 KB
#include <bits/stdc++.h>

using i64 = long long;

struct SegmentTree {
    int n;
    std::vector<int> t;
    SegmentTree(int n) : n(n), t(2 * n) {}
    void modify(int p, int val) {
        for (t[p += n] = val; p > 1; p >>= 1) {
            t[p >> 1] = t[p] ^ t[p ^ 1];
        }
    }
    int get(int l, int r) {
        int res = 0;
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) {
                res ^= t[l++];
            }
            if (r & 1) {
                res ^= t[--r];
            }
        }
        return res;
    }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n, q;
    std::cin >> n >> q;
    
    std::vector<int> a(n);
    SegmentTree s1(n), s2(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        if (i % 2 == 0) {
            s1.modify(i, a[i]);
        } else {
            s2.modify(i, a[i]);
        }
    }
    
    while (q--) {
        int type;
        std::cin >> type;
        if (type == 1) {
            int p, v;
            std::cin >> p >> v;
            p--;
            if (p % 2 == 0) {
                s1.modify(p, v);
            } else {
                s2.modify(p, v);
            }
            a[p] = v;
        } else {
            int l, r;
            std::cin >> l >> r;
            l--;
            if (l % 2 == 0) {
                std::cout << s1.get(l, r) << "\n";
            } else {
                std::cout << s2.get(l, r) << "\n";
            }
        }
    }
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 157 ms 6152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -