样例都过了啊,为什么还是0
查看原帖
样例都过了啊,为什么还是0
765076
GAOSY楼主2024/5/22 20:08
#include <bits/stdc++.h>
using namespace std;
int n,m,a[200020];
struct bit{
	int c[200020];
	inline int lowbit(int x){
		return x&(-x);
	}
	inline void change(int x,int y){
		while(x<=n){
			c[x]^=y;
			x+=lowbit(x);
		}
	}
	inline int query(int x){
		int ans=0;
		while(x){
			ans^=c[x];
			x-=lowbit(x);
		}
		return ans;
	}
}tree[2];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		tree[i&1].change(i,a[i]);
	}
	for(int i=1;i<=m;i++){
		int op,x,y;
		cin>>op>>x>>y;
		if(op==1){
			tree[x&1].change(x,a[x]^y);
			a[x]=y;
		}
		else{
			if((x&1)^(y&1))
				cout<<0<<"\n";
			cout<<(tree[x&1].query(y)^tree[x&1].query(x-1))<<"\n";
		}
	}
}
2024/5/22 20:08
加载中...