# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
444649 | drkarlicio2107 | XORanges (eJOI19_xoranges) | C++14 | 636 ms | 8684 KiB |
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; int fen_parni [200010]; int fen_neparni [200010]; int l [200010];
void add_parni (int a, int v){
for (a; a<200000; a+= a & -a) fen_parni[a]^=v;
}
int query_parni (int a){
int res=0;
for (a; a>0; a-= a & -a) res^=fen_parni[a];
return res;
}
void add_neparni (int a, int v){
for (a; a<200000; a+= a & -a) fen_neparni[a]^=v;
}
int query_neparni (int a){
int res=0;
for (a; a>0; a-= a & -a) res^=fen_neparni[a];
return res;
}
int main(){
int n,q; cin >> n >> q;
for (int i=1; i<n+1; i++){
int a; cin >> a;
if (i%2==0) add_parni (i, a);
else add_neparni (i, a);
l[i]=a;
/*
if (i%2==0) cout << query_parni (i) << endl;
else cout << query_neparni (i) << endl;
*/
}
for (int i=0; i<q; i++){
int x; cin >> x;
if (x==1){
int a, b; cin >> a >> b;
if (a%2==0){
add_parni (a, l[a]); add_parni (a, b);
}
else {
add_neparni (a, l[a]); add_neparni (a, b);
}
l[a]=b;
}
else {
int l, r; cin >> l >> r;
if ((r-l+1)%2==0) cout << 0 << endl;
else {
if (l==1){
if (r%2==0) cout << query_parni (r) << endl;
else cout << query_neparni (r) << endl;
}
else if (r%2==0 && (l-1)%2==1) cout << query_parni (r)-query_neparni (l-1) << endl;
else if (r%2==0 && (l-1)%2==0) cout << query_parni (r)-query_parni (l-1) << endl;
else if (r%2==1 && (l-1)%2==1) cout << query_neparni (r)-query_neparni (l-1) << endl;
else if (r%2==1 && (l-1)%2==0) cout << query_neparni (r)-query_parni (l-1) << endl;
}
}
}
}
Compilation message (stderr)
# | 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... |