#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN=1e6;
#define fi first
#define se second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mid (l+r)/2
#define sz(a) int((a).size())
#define all(a) a.begin(),a.end()
#define mod 1000000007LL
#define endl "\n"
#define PRINT(x) cout<<#x<<'-'<<x<<endl
ll n, m, k, q, l, r, x, y, z, res=0, tmp=0;
string s,t;
ll a[MAXN],seg[MAXN*4][2];
void build(int node, int l, int r){
if(l==r){
seg[node][l%2]=a[l];
return;
}
build(2*node,l,mid); build(2*node+1,mid+1,r);
seg[node][0]=seg[2*node][0]^seg[2*node+1][0];
seg[node][1]=seg[2*node][1]^seg[2*node+1][1];
}
void update(int node, int l, int r, int idx, int val){
if(l==r){
seg[node][l%2]=val;
return;
}
if(idx<=mid) update(2*node,l,mid,idx,val);
else update(2*node+1,mid+1,r,idx,val);
seg[node][0]=seg[2*node][0]^seg[2*node+1][0];
seg[node][1]=seg[2*node][1]^seg[2*node+1][1];
}
int query(int node,int l,int r,int L,int R,int parnost){
if(L<=l && r<=R) return seg[node][parnost];
int rez=0;
if(L<=mid) rez^=query(2*node,l,mid,L,R,parnost);
if(R>mid) rez^=query(2*node+1,mid+1,r,L,R,parnost);
return rez;
}
void solve(){
cin>>n>>q;
for(int i=1;i<=n;i++){
cin>>a[i];
}
build(1,1,n);
while(q--){
int tip;
cin>>tip;
if(tip==1){
int pos;
cin>>pos>>x;
update(1,1,n,pos,x);
}
else{
int l,r;
cin>>l>>r;
if(!((l-r+1)%2)){
cout<<0<<endl;
}
cout<<query(1,1,n,l,r,l%2)<<endl;
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
int t;
//cin>>t;
t=1;
while(t--){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
295 ms |
17092 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |