#include <bits/stdc++.h>
#define INF 1e18
#define LL long long
#define int long long
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e18;
const int mxn = 2e5 + 5;
struct FenwickTree{
vector<int> bit;
int n;
FenwickTree(int _n){
n = _n + 69;
bit.resize(n,0);
}
void update(int pos,int val){
for(;pos<n;pos += pos & -pos)bit[pos] ^= val;
}
int query(int pos){
int ans = 0;
for(;pos;pos -= pos & -pos)ans ^= bit[pos];
return ans;
}
int range(int l,int r){
if(l == 1)return query(r);
return query(r) - query(l - 1);
}
};
int A[mxn];
void solve(){
int n,q;
cin>>n>>q;
FenwickTree odd(n), even(n);
for(int i = 1;i<=n;i++)cin>>A[i];
for(int i = 1;i<=n;i++){
if(i % 2 == 0){
even.update(i,A[i]);
}else{
odd.update(i, A[i]);
}
}
while(q--){
int o,a,b;
cin>>o>>a>>b;
if(o == 1){
if(a % 2 == 0){
even.update(a,A[a]);
A[a] = b;
even.update(a,A[a]);
}
else{
odd.update(a,A[a]);
A[a] = b;
odd.update(a,A[a]);
}
continue;
}
// cout<<a<<" "<<b<<endl;
if((b - a + 1) % 2 == 0)cout<<0<<endl;
else if(a % 2 == 0)cout<<even.range(a,b)<<endl;
else cout<<odd.range(a,b)<<endl;
}
}
int32_t main() {
#ifdef ONLINE_JUDGE
ios_base::sync_with_stdio(false);
cin.tie(0);
#endif
solve();
// int n;
// cin >>n;
// FenwickTree fwt(n);
// int q;
// cin>>q;
// while(q--){
// int op;
// cin>>op;
// if(op == 1){
// int pos,val;
// cin>>pos>>val;
// fwt.update(pos,val);
// }else{
// int pos;
// cout<<fwt.query(pos)<<endl;
// }
// }
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
386 ms |
11020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |