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>
using namespace std;
struct fenwick{
vector <int> fenw;
int n;
fenwick(int n) : fenw(n + 1, 0), n(n) {}
void upd(int i, int v){
for (; i <= n; i += i & -i ) fenw[i] ^= v;
}
int get(int i){
int cnt = 0;
for (; i > 0; i -= i & -i ) cnt ^= fenw[i];
return cnt;
}
int qry(int l, int r){
if ( (r - l) & 1 ) return 0;
return get(r) ^ get(l - 1);
}
};
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, q; cin >> n >> q;
vector <int> a(n + 1);
vector <fenwick> fn(2, fenwick(n + 1));
for ( int i = 1; i <= n; i++ ){
int x; cin >> x;
a[i] = x;
fn[i & 1].upd(i, x);
}
while ( q-- ){
int t, l, u; cin >> t >> l >> u;
if ( t == 1 ){
fn[l & 1].upd(l, u);
fn[l & 1].upd(l, a[l]);
a[l] = u;
} else cout << fn[l & 1].qry(l, u) << '\n';
}
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... |