QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#153081 | #6795. Everyone Loves Playing Games | LFCode | RE | 0ms | 0kb | C++14 | 1.2kb | 2023-08-29 11:01:53 | 2023-08-29 11:01:55 |
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;}
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: 0
Runtime Error
input:
2 1 1 6 3 4 1 2 2 1 3 4 6 5 4 2 2