#include<bits/stdc++.h>
using namespace std;
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for(int i=int(n)-1;i>=int(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define sz(x) int(x.size())
#define all(x) begin(x),end(x)
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> ii;
struct FTree{
int n;
vi ft,v;
FTree(int _n):n(_n+4),ft(n,0),v(n,0){}
void upd(int i, int x){
for(++i;i<n;i+=i&-i) ft[i]^=x;
}
void set(int i, int x){
upd(i,v[i]^x);
v[i]=x;
}
int get(int i){
int s=0;
for(++i;i;i-=i&-i) s^=ft[i];
return s;
}
int query(int l, int r){
return get(r)^get(l-1);
}
};
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n,q;
cin>>n>>q;
FTree even(n),odd(n);
forn(i,n){
int x;
cin>>x;
if(i&1) odd.set(i,x);
else even.set(i,x);
}
forn(_,q){
int t;
cin>>t;
if(t==1){
int p,x;
cin>>p>>x;
p--;
if(p&1) odd.set(p,x);
else even.set(p,x);
}else{
int l,r;
cin>>l>>r;
l--,r--;
if((r-l)&1) cout<<"0\n";
else{
if(l&1) cout<<odd.query(l,r)<<'\n';
else cout<<even.query(l,r)<<'\n';
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
456 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
2 ms |
648 KB |
Output is correct |
13 |
Correct |
2 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
61 ms |
9360 KB |
Output is correct |
2 |
Correct |
57 ms |
9552 KB |
Output is correct |
3 |
Correct |
59 ms |
9720 KB |
Output is correct |
4 |
Correct |
55 ms |
9160 KB |
Output is correct |
5 |
Correct |
62 ms |
9312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
456 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
2 ms |
648 KB |
Output is correct |
13 |
Correct |
2 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
584 KB |
Output is correct |
15 |
Correct |
61 ms |
9360 KB |
Output is correct |
16 |
Correct |
57 ms |
9552 KB |
Output is correct |
17 |
Correct |
59 ms |
9720 KB |
Output is correct |
18 |
Correct |
55 ms |
9160 KB |
Output is correct |
19 |
Correct |
62 ms |
9312 KB |
Output is correct |
20 |
Correct |
62 ms |
9216 KB |
Output is correct |
21 |
Correct |
62 ms |
9264 KB |
Output is correct |
22 |
Correct |
59 ms |
9144 KB |
Output is correct |
23 |
Correct |
56 ms |
9040 KB |
Output is correct |
24 |
Correct |
56 ms |
9040 KB |
Output is correct |