QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#268368#7765. Xor Mastersongziyan0 775ms111304kbC++143.6kb2023-11-28 16:33:542023-11-28 16:34:03

Judging History

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

  • [2023-11-28 16:34:03]
  • 评测
  • 测评结果:0
  • 用时:775ms
  • 内存:111304kb
  • [2023-11-28 16:33:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#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,q;
ull c[N],a[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;
			for(int i=63;i>=0;i--)
				if((y>>i)&1)y^=s[i];
			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];
			printf("%lld %lld %lld\n",x,y,v);
			//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;
}
/*
*/

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 52896kb

input:

2000 2000
1860495733 462603674 3739839441 759356520 47330263 550811730 2301200895 989240351 2499503801 2624225494 2123076812 1180966826 238739434 488666688 784742950 2583466952 4111371941 2335988605 2583741355 933716686 1644403538 1970423306 304500250 905101643 1814942168 1136358764 88729799 1577263...

output:

723 1136 1878695375
867006634793
65 1604 392096781
3417908523709
229 989 1059226955
1658469159497
557 941 2771811738
794670034691
1269 1376 2425745405
239792547603
422 1145 3105760858
1587489100966
582 872 64981803
592222190840
565 1217 908317824
1343829228543
506 967 572318425
971235608682
1509 176...

result:

wrong answer 1st lines differ - expected: '867006634793', found: '723 1136 1878695375'

Subtask #2:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 775ms
memory: 111304kb

input:

500000 100000
12261386944926786495 7846697792998647383 16622924885320463714 170129022271213944 12625257523700625864 7684671687986103560 11532026873918423068 1131776055566669037 8263146651412710501 17872572061246021001 5017109039248728310 11088626167542318645 13810119722795416818 10928315716094262229...

output:

60039 78390 -381242844980751463
12337138966997790840
220152 234557 2520429477408013125
11593856511006775316
298370 477016 4885160900820097868
5653988472748567965
386746 462892 -334575226641877585
6281173414355612100
92439 191087 -8950700434610819923
18027295039962377213
26667 420161 1442764672607009...

result:

wrong answer 1st lines differ - expected: '12337138966997790840', found: '60039 78390 -381242844980751463'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 169ms
memory: 62768kb

input:

100000 100000
860905160 3192911636 290327446 2020707113 959258245 454185039 421895589 1070265496 2218913641 1684685660 1206723673 2606734467 4247254571 3341954386 3805299640 1702270353 2472053741 2816060613 1307901348 2702949728 879391505 884661815 330738731 1575749344 1239158446 2099693858 67466644...

output:

1 77766 0
208755389215975
1 46803 0
125497785366837
1 60478 0
162446748431411
1 23498 0
63166834945113
1 12294 0
33018804920229
1 33246 0
89343160639243
1 13696 0
36805816758195
1 15172 0
40790494641758
1 5194 0
13928126471189
1 99644 0
267168502433672
1 64993 0
191989403472418
1 93642 0
27635093675...

result:

wrong answer 1st lines differ - expected: '208755389215975', found: '1 77766 0'

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%