QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#153082#6795. Everyone Loves Playing GamesLFCodeWA 21ms1496kbC++141.2kb2023-08-29 11:02:152023-08-29 11:02:15

Judging History

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

  • [2023-08-29 11:02:15]
  • 评测
  • 测评结果:WA
  • 用时:21ms
  • 内存:1496kb
  • [2023-08-29 11:02:15]
  • 提交

answer

#include<cstdio>
#define int long long
const int N=60;
struct LinearBasis{
	int a[N];
	bool clear(){for(int i=59;i+1;i--)a[i]=0;return true;}
	bool push(int x){
		for(int i=59;i+1;i--){
			if(!((x>>i)&1))continue;
			if(a[i]){x^=a[i];continue;}
			for(int j=0;j<i;j++)x^=a[j];
			for(int j=59;j>i;j--)if((a[j]>>i)&1)a[j]^=x;
			a[i]=x;return true;
		}
		return false;
	}
	int &operator [](int x){return a[x];}
	int qmin(int x){
		for(int i=59;i+1;i--)if((x>>i)&1)x^=a[i];
		return x;
	}
	int qmax(int x){
		for(int i=59;i+1;i--)if(!((x>>i)&1))x^=a[i];
		return x;
	}
};
LinearBasis A,B,C;
int read(){
	char ch=getchar();int nn=0,ssss=1;
	while(ch<'0'||ch>'9'){if(ch=='-')ssss*=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){nn=nn*10+(ch-'0');ch=getchar();}
	return nn*ssss;
}
bool solve(){
	int n=read();int m=read();int x=0;
	A.clear();B.clear();C.clear();
	for(int i=1;i<=n;i++){
		int a=read();int b=read();
		x^=a;A.push(a^b);
	}
	for(int i=1;i<=m;i++){
		int a=read();int b=read();
		x^=a;B.push(a^b);
	}
	for(int i=59;i+1;i--)if(A[i])C.push(B.qmin(A[i]));
	printf("%lld\n",C.qmax(x));
	return true;
}
signed main(){
	int T=read();
	while(T--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 1496kb

input:

2
1 1
6 3
4 1
2 2
1 3
4 6
5 4
2 2

output:

2
2

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 21ms
memory: 1484kb

input:

15
10000 19
393592642880030158 136857754781138651
64253273480262588 14313422237514072
307460297920437500 243820607396725
21817935197991240 483662625803120946
101295580681553439 176530315178675718
299210522568785323 76213955574929634
71280408782239858 46474979272278520
355918902735266055 227582800425...

output:

1045497019549876223
1087619310009974783
489679391899516927
1008806316530991103
755042786557820927
849560468316946431
442991585563508735
962050937474514943
914491931310948351
336927333829050367
117469991292763453
804613813113454590
886246201177931775
822168036188291071
32532004279158071

result:

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