QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#268356#7765. Xor Mastersongziyan0 791ms114752kbC++143.6kb2023-11-28 16:25:582023-11-28 16:25:59

Judging History

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

  • [2023-11-28 16:25:59]
  • 评测
  • 测评结果:0
  • 用时:791ms
  • 内存:114752kb
  • [2023-11-28 16:25:58]
  • 提交

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;
		printf("%lld\n",op);
		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];
			//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

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 9ms
memory: 55072kb

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:

1
1
3
867006634793
1
1
3
3417908523709
1
1
1
3
1658469159497
3
794670034691
1
3
239792547603
3
1587489100966
3
592222190840
3
1343829228543
1
1
3
971235608682
3
570627566936
3
1219913932169
3
588622963947
3
2129364199613
1
1
3
1007100392608
1
1
3
3133419422156
3
3145027622054
3
2599298084940
3
17293...

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 791ms
memory: 114752kb

input:

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

output:

3
12337138966997790840
3
11593856511006775316
3
5653988472748567965
3
6281173414355612100
3
18027295039962377213
3
2903343914316621940
3
9422461876307420631
3
76690753587353877
3
798815192298668980
3
10137130634921141648
3
13914431888234873359
3
10192090671035649089
3
11569745711967074397
3
12303071...

result:

wrong answer 1st lines differ - expected: '12337138966997790840', found: '3'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 163ms
memory: 68856kb

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:

2
3
208755389215975
2
2
3
125497785366837
2
2
3
162446748431411
3
63166834945113
3
33018804920229
3
89343160639243
2
3
36805816758195
2
3
40790494641758
2
2
3
13928126471189
2
3
267168502433672
2
2
2
3
191989403472418
3
276350936750564
2
3
11189666657474
3
133862444125402
2
3
92684260245650
3
179275...

result:

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

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%