QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#268321#7765. Xor MastersongziyanCompile Error//C++143.5kb2023-11-28 15:47:522023-11-28 15:47:53

Judging History

你现在查看的是最新测评结果

  • [2023-11-28 15:47:53]
  • 评测
  • [2023-11-28 15:47:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int ull
#define gc getchar
// char buf[1<<22],*p1,*p2;
// #define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin),p1==p2)?0:*p1++)
inline int read(){
	int x=0,f=1;char ch=gc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-48,ch=gc();
	return x*f;
}
#define rd read()
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define ull unsigned long long
const int N=5e5+5;
int n,a[N],q;
ull c[N];
void add(int x,ull v){
	for(;x<=n;x+=(x&(-x)))
		c[x]^=v;
}
ull sum(int x){
	ull res=0;
	for(;x;x-=(x&(-x)))
		res^=c[x];
	return res;
}
struct node{
	vector<ull>d;
	node operator+(const node &x){
		int dlen=d.size(),xdlen=x.d.size();
		node res;
		res.d.resize(max(dlen,xdlen));
		ull k=0;
		for(int i=0;i<min(dlen,xdlen);i++){
			res.d[i]=d[i]^x.d[i]^k;
			k=(d[i]&x.d[i])|(d[i]&k)|(x.d[i]&k);
		}
		for(int i=min(dlen,xdlen);i<max(dlen,xdlen);i++){
			if(dlen<xdlen){
				res.d[i]=x.d[i]^k;
				k=x.d[i]&k;
			}else{
				res.d[i]=d[i]^k;
				k=d[i]&k;
			}
		}
		if(k)res.d.pb(k);
		return res;
	}
	ull res(){
		ull ans=0;
		for(int i=0;i<d.size();i++)ans+=(1ull<<i)*d[i];
		return ans;
	}
};
node tr[N<<2];
ull tag[N<<2];
int len[N<<2];
void build(int x,int l,int r){
	len[x]=r-l+1;
	if(l==r){
		tr[x].d.pb(sum(l));
		return;
	}
	int mid=(l+r)>>1;
	build(x<<1,l,mid);
	build(x<<1|1,mid+1,r);
	tr[x]=tr[x<<1]+tr[x<<1|1];
}
void addtag(int x,ull v){
	tag[x]^=v;
	ull jw=0;
	for(int i=0;i<tr[x].d.size();i++){
		ull t=jw;
		if((len[x]>>i)&1){
			jw&=(tr[x].d[i]&v);
			tr[x].d[i]^=v^t;
		}else{
			jw|=(tr[x].d[i]&v);
			tr[x].d[i]^=t;
		}
	}
}
void pushdown(int x){
	if(tag[x]){
		addtag(x<<1,tag[x]);
		addtag(x<<1|1,tag[x]);
		tag[x]=0;
	}
}
void upd(int x,int l,int r,int ql,int qr,ull v){
	if(!v)return;
	if(ql<=l&&r<=qr){
		addtag(x,v);
		return;
	}
	pushdown(x);
	int mid=(l+r)>>1;
	if(ql<=mid)upd(x<<1,l,mid,ql,qr,v);
	if(qr>mid)upd(x<<1|1,mid+1,r,ql,qr,v);
	tr[x]=tr[x<<1]+tr[x<<1|1];
}
ull qry(int x,int l,int r,int ql,int qr){
	if(ql<=l&&r<=qr)return tr[x].res();
	pushdown(x);
	int mid=(l+r)>>1;ull ans=0;
	if(ql<=mid)ans+=qry(x<<1,l,mid,ql,qr);
	if(qr>mid)ans+=qry(x<<1|1,mid+1,r,ql,qr);
	return ans;
}
ull s[70];
ull insert(ull v){
	for(int i=63;i>=0;i--){
		if((v>>i)&1){
			if(!s[i]){
				for(int j=i-1;j>=0;j--)
					if((v>>j)&1)v^=s[j];
				s[i]=v;
				for(int j=63;j>i;j--)
					if((s[j]>>i)&1)s[j]^=v;
				return i;
			}
			v^=s[i];
		}
	}
	return 64;
}
void build(int x,int l,int r,ull v){
	pushdown(x);
	if(l==r){
		//printf("%lld: ",l);
		tr[x].d[0]=max(tr[x].d[0],tr[x].d[0]^v);
		//printf("%llu\n",tr[x].res());
		return;
	}
	int mid=(l+r)>>1;
	build(x<<1,l,mid,v);
	build(x<<1|1,mid+1,r,v);
	tr[x]=tr[x<<1]+tr[x<<1|1];
	//printf("%lld,%lld\n",l,r);
	//printf("%lld\n",tr[x].res());
}
void init(ull v){
	build(1,1,n,v);
	//puts("");
}
signed main(){
	n=rd;q=rd;
	for(int i=1;i<=n;i++)a[i]=rd,add(i,a[i]);
	build(1,1,n);
	while(q--){
		int op,x,y;
		op=rd;
		if(op==1){
			x=rd;y=rd;
			add(x,y);
			upd(1,1,n,x,n,y);
		}
		if(op==2){
			y=rd;
			ull t=insert(y);
			if(t!=64)init(s[t]);//,puts("qwq");
		}
		if(op==3){
			x=rd;y=rd;
			ull v=sum(x-1);
			for(int i=63;i>=0;i--)
				if((v>>i)&1)v^=s[i];
			//for(int i=1;i<=n;i++)printf("%llu ",qry(1,1,n,i,i));puts("");
			upd(1,1,n,x,y,v);
			printf("%llu\n",qry(1,1,n,x,y));
			upd(1,1,n,x,y,v);
		}
	}
	return 0;
}
/*
*/

Details

answer.code:3:13: error: ‘ull’ does not name a type
    3 | #define int ull
      |             ^~~
answer.code:7:8: note: in expansion of macro ‘int’
    7 | inline int read(){
      |        ^~~
answer.code:3:13: note: the macro ‘ull’ had not yet been defined
    3 | #define int ull
      |             ^~~
answer.code:7:8: note: in expansion of macro ‘int’
    7 | inline int read(){
      |        ^~~
answer.code:17: note: it was later defined here
   17 | #define ull unsigned long long
      | 
answer.code: In function ‘int main()’:
answer.code:13:12: error: ‘read’ was not declared in this scope; did you mean ‘fread’?
   13 | #define rd read()
      |            ^~~~
answer.code:152:11: note: in expansion of macro ‘rd’
  152 |         n=rd;q=rd;
      |           ^~