#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 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
60 ms |
9552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |