玄关 求调
查看原帖
玄关 求调
914413
xiaozhichen123楼主2024/11/30 11:47

样例没过 求找错

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1000001;
int n,m,x,y,k,c1[N],c2[N],q;
int jo(int x,int y) {
	if((y-x)%2==0) {
		return 0;
	}
	return 1;
}
int lowbit(int x) {
	return x&(-x);
}
void yihuo1(int x,int k) {
	while(x<=(n+1)/2) {
		c1[x]^=k;
		x+=lowbit(x);
	}
}
void yihuo2(int x,int k) {
	while(x<=n/2) {
		c2[x]^=k;
		x+=lowbit(x);
	}
}
int get1(int x) {
	int sum=0;
	while(x>0) {
		sum^=c1[x];
		x-=lowbit(x);
	}
	return sum;
}
int get2(int x) {
	int sum=0;
	while(x>0) {
		sum^=c2[x];
		x-=lowbit(x);
	}
	return sum;
}
signed main() {
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		if(i%2==1){
			cin>>c1[(i+1)/2];
		}else{
			cin>>c2[i/2];
		}
	}
	for(int i=1; i<=m; i++) {
		cin>>q>>x>>y;
		if(q==1) {
			if(x%2==1) {
				yihuo1((x+1)/2,c1[(x+1)/2]^y);
			} else {
				yihuo2(x/2,c2[x/2]^y);
			}
		} else {
			if(jo(x,y)) {
				cout<<0<<endl;
			}else{
				if(x%2==1){
					int h=get1((y+1)/2)^get1((x+1)/2-1);
					cout<<h<<endl;
				}else{
					int h=get2(y/2)^get2(x/2-1);
					cout<<h<<endl;
				}
			}
		}
	}
	return 0;
}
2024/11/30 11:47
加载中...