# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
220350 | Matteo_Verz | XORanges (eJOI19_xoranges) | C++11 | 149 ms | 8788 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.
/*
`-/oo+/- ``
.oyhhhhhhyo.`od
+hhhhyyoooos. h/
+hhyso++oosy- /s
.yoooossyyo:``-y`
..----.` ``.-/+:.`
`````..-::/.
`..```.-::///`
`-.....--::::/:
`.......--::////:
`...`....---:::://:
`......``..--:::::///:`
`---.......--:::::////+/`
----------::::::/::///++:
----:---:::::///////////:`
.----::::::////////////:-`
`----::::::::::/::::::::-
`.-----:::::::::::::::-
...----:::::::::/:-`
`.---::/+osss+:`
``.:://///-.
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cmath>
using namespace std;
const int INF = 2e9;
const int N = 2e5;
int n, q;
int v[5 + N];
class AIB{
private:
int a[5 + N];
int lsb(int i){
return (i & (-i));
}
public:
void Build(int pos, int val){
for(int i = pos; i <= n; i += lsb(i))
a[i] = a[i] ^ val;
}
void Update(int pos, int val){
for(int i = pos; i <= n; i += lsb(i))
a[i] = a[i] ^ v[pos] ^ val;
v[pos] = val;
}
int Query(int pos){
int s(0);
for(int i = pos; i >= 1; i -= lsb(i))
s ^= a[i];
return s;
}
};
AIB FenwOdd, FenwEven;
int main() {
#ifdef CP
freopen("xoranges.in", "r", stdin);
freopen("xoranges.out", "w", stdout);
#endif // CP
scanf("%d%d", &n, &q);
for(int i = 1; i <= n; i++){
scanf("%d", &v[i]);
if(i & 1) FenwOdd.Build(i, v[i]);
else FenwEven.Build(i, v[i]);
}
while(q--){
int t, x, y;
scanf("%d%d%d", &t, &x, &y);
if(t == 1){
if(x & 1) FenwOdd.Update(x, y);
else FenwEven.Update(x, y);
} else{
if((x - y + 1) & 1){
if(y & 1) printf("%d\n", FenwOdd.Query(y) ^ FenwOdd.Query(x - 2));
else printf("%d\n", FenwEven.Query(y) ^ FenwEven.Query(x - 2));
} else printf("0\n");
}
}
return 0;
}
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... |