QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#152243#6795. Everyone Loves Playing Gamesdo_while_trueAC ✓31ms3560kbC++202.6kb2023-08-27 20:22:522023-08-27 20:22:54

Judging History

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

  • [2023-08-27 20:22:54]
  • 评测
  • 测评结果:AC
  • 用时:31ms
  • 内存:3560kb
  • [2023-08-27 20:22:52]
  • 提交

answer

#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<random>
#include<assert.h>
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n'
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n'
#define DE(fmt,...) fprintf(stderr, "Line %d : " fmt "\n",__LINE__,##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef pair<ll,int>pli;
typedef pair<ll,ll>pll;
typedef pair<int,ll>pil;
typedef vector<int>vi;
typedef vector<ll>vll;
typedef vector<pii>vpii;
typedef vector<pll>vpll;
template<typename T>T cmax(T &x, T y){return x=x>y?x:y;}
template<typename T>T cmin(T &x, T y){return x=x<y?x:y;}
template<typename T>
T &read(T &r){
	r=0;bool w=0;char ch=getchar();
	while(ch<'0'||ch>'9')w=ch=='-'?1:0,ch=getchar();
	while(ch>='0'&&ch<='9')r=r*10+(ch^48),ch=getchar();
	return r=w?-r:r;
}
template<typename T1,typename... T2>
void read(T1 &x,T2& ...y){read(x);read(y...);}
const int mod=998244353;
inline void cadd(int &x,int y){x=(x+y>=mod)?(x+y-mod):(x+y);}
inline void cdel(int &x,int y){x=(x-y<0)?(x-y+mod):(x-y);}
inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
inline int del(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
int qpow(int x,int y){
	int s=1;
	while(y){
		if(y&1)s=1ll*s*x%mod;
		x=1ll*x*x%mod;
		y>>=1;
	}
	return s;
}
ll bit(int x){return 1ll<<x;}
int n,m;
struct linerbase{
	ll p[61];
	void clear(){for(int i=0;i<=60;i++)p[i]=0;}
	void ins(ll x){
		for(int i=60;~i;--i)
			if(bit(i)&x){
				if(p[i])x^=p[i];
				else{
					p[i]=x;
					break;
				}
			}
	}
	ll qmx(ll x){
		for(int i=60;~i;--i)
			if(bit(i)&x);
			else x^=p[i];
		return x;
	}
	ll qmn(ll x){
		for(int i=60;~i;--i)
			if(bit(i)&x)x^=p[i];
		return x;
	}
}A,B,C;
void solve(){
	read(n,m);
	ll s=0;A.clear();B.clear();C.clear();
	for(int i=1;i<=n;i++){
		ll x,y;read(x,y);
		s^=x;
		A.ins(x^y);
	}
	for(int i=1;i<=m;i++){
		ll x,y;read(x,y);
		s^=x;
		B.ins(x^y);
	}
	for(int i=0;i<=60;i++)
		if(A.p[i])
			C.ins(B.qmn(A.p[i]));
	cout<<C.qmx(B.qmn(s))<<'\n';
}
signed main(){
	#ifdef do_while_true
//		assert(freopen("data.in","r",stdin));
//		assert(freopen("data.out","w",stdout));
	#endif
	int T;read(T);
	while(T--)solve();
    #ifdef do_while_true
//		cerr<<'\n'<<"Time:"<<1.0*clock()/CLOCKS_PER_SEC*1000<<" ms"<<'\n';
	#endif
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3560kb

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: 0
Accepted
time: 31ms
memory: 3452kb

input:

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

output:

2199023255551
5910974510923775
17179869183
1008806316530991103
855638015
2424831
163208757247
12884901887
12582911
17179869183
402595213
2199023255549
10485759
983039
2265548478697

result:

ok 15 lines