求助,为什么会 CE /yiw
查看原帖
求助,为什么会 CE /yiw
339992
Icy_Fire楼主2020/11/24 19:35

评测记录

https://www.luogu.com.cn/record/42519736

在本地编译过了的

#include<cstdio>
#include<algorithm>
using namespace std;
inline int read(){
	int x=0; char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x;
}
const int maxn=6e5+10;
int n,m,s[maxn];
int trie[maxn*25][2],root[maxn],latest[maxn*25]={-1},tot=0;
void Insert(int p,int q,int k,int i){
	if(k<0){
		latest[q]=i;
		return;
	}
	int c=s[i]>>k&1;
	if(p) trie[q][c^1]=trie[p][c^1];
//	printf("%d %d \n",q,tot);
	trie[q][c]=++tot;
	Insert(trie[p][c],trie[q][c],k-1,i);
	latest[q]=max(latest[trie[q][0]],latest[trie[q][1]]);
}
int ask(int p,int l,int k,int x){
	if(k<0) return s[latest[p]]^x;
	int c=x>>k&1;
	if(latest[trie[p][c^1]]>=l)
		return ask(trie[p][c^1],l,k-1,x);
	return ask(trie[p][c],l,k-1,x);
}
int main(){
	n=read(),m=read();
	Insert(0,root[0]=++tot,24,0);
	for(int i=1;i<=n;i++){
		s[i]=s[i-1]^read();
		root[i]=++tot;
		Insert(root[i-1],root[i],24,i);
	} 
	while(m--){
		char op[2];
		scanf("%s",op);
		if(op[0]=='A'){
			n++; s[n]=s[n-1]^read();
			Insert(root[n-1],root[n]=++tot,24,n);
		}
		else{
			int l=read(),r=read(),x=read();
			printf("%d\n",ask(root[r-1],l-1,24,x^s[n]));
		}
	}
//	for(int i=1;i<=tot;i++)
//		printf("%d : [0] %d , [1] %d\n",i,trie[i][0],trie[i][1]);
	return 0;
} 
2020/11/24 19:35
加载中...