Submission #759104

# Submission time Handle Problem Language Result Execution time Memory
759104 2023-06-15T18:46:45 Z Pekiban XORanges (eJOI19_xoranges) C++17
38 / 100
109 ms 14160 KB
#include <bits/stdc++.h>

using namespace std;


struct segtree {
    int n;
    int st[800002];
    void build(const vector<int> &v, int i, int l2, int r2) {
        if (l2 == r2) {
            st[i] = v[l2];
            return;
        }
        int m2 = (l2+r2)/2;
        build(v, 2*i, l2, m2);
        build(v, 2*i+1, m2+1, r2);
        st[i] = st[2*i]^st[2*i+1];
    }
    void build(const vector<int> &v) {
        build(v, 1, 0, n-1);
    }
    void update(int l, int x, int i, int l2, int r2) {
        if (l2 == r2) {
            st[i] = x;
            return;
        }
        int m2 = (l2 + r2)/2;
        if (l <= m2) {
            update(l, x, 2*i, l, m2);
        }
        else {
            update(l, x, 2*i+1, m2+1, l);
        }
        st[i] = st[2*i]^st[2*i+1];
    }
    void update(int l, int x) {
        update(l, x, 1, 0, n-1);
    }
    int query(int l, int r, int i, int l2, int r2) {
        if (l <= l2 && r2 <= r) {
            return st[i];
        }
        int s = 0;
        int m2 = (l2 + r2)/2;
        if (l <= m2) {
            s^=query(l, r, 2*i, l2, m2);
        }
        if (m2+1 <= r) {
            s^=query(l, r, 2*i+1, m2+1, r2);
        }
        return s;
    }
    int query(int l, int r) {
        return query(l, r, 1, 0, n-1);
    }
};



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> sx(n+3), a(n+3);
    cin >> a[0]; sx[0] = a[0];
    for (int i = 1; i < n; ++i) {
        cin >> a[i];
        if (i%2==0) {
            sx[i] = a[i];
        }
    }
    segtree b, c;
    b.n = n, c.n = n;
    b.build(sx), c.build(a);
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int l, x;
            cin >> l >> x;
            l--;
            c.update(l, x);
            if (l % 2 == 0) {
                b.update(l, x);
            }
        }
        else {
            int l, r;
            cin >> l >> r;
            l--, r--;
            if ((r-l) %2 ) {
                cout << 0 << '\n';
            }
            else {
                if (l%2 == 0) {
                    cout << b.query(l, r) << '\n';
                }
                else {
                    cout << (b.query(l, r) ^ c.query(l, r)) << '\n';
                }
            }
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6484 KB Output is correct
2 Correct 3 ms 6584 KB Output is correct
3 Correct 3 ms 6484 KB Output is correct
4 Correct 3 ms 6484 KB Output is correct
5 Correct 4 ms 6612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 106 ms 14144 KB Output is correct
2 Correct 109 ms 14160 KB Output is correct
3 Correct 105 ms 14156 KB Output is correct
4 Correct 97 ms 13744 KB Output is correct
5 Correct 97 ms 13764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6484 KB Output isn't correct
2 Halted 0 ms 0 KB -