This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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';
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |