QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#448360#8722. 卡牌游戏275307894aTL 0ms0kbC++141.9kb2024-06-19 15:42:222024-06-19 15:42:23

Judging History

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

  • [2024-06-19 15:42:23]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-06-19 15:42:22]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=5e5+5,M=N*4+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(time(0));
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int n,m;
map<pair<vector<int>,vector<int> >,int> f;
int dfs(vector<int> A,vector<int> B){
	if(!*max_element(all(B))) return 0;
	if(!*max_element(all(A))) return 1;
	auto p=make_pair(A,B);
	if(f.count(p)) return f[p];
	int &ans=f[p];
	for(int i=0;i<n;i++) if(A[i]){
		A[i]--;
		for(int j=0;;j++){
			A[i]-=j;B[i]-=j;
			if(!dfs(A,B)) break;
			A[i]+=j;B[i]+=j;
			if(B[i]==j)return ans=1;
			B[i]-=j+1;A[i]-=j;
			if(!dfs(B,A))return ans=1;
			B[i]+=j+1;A[i]+=j;
			if(A[i]==j) break;
		}
		A[i]++;
	}
	// cerr<<"A ";for(int i:A) cerr<<i<<' ';cerr<<'\n';
	// cerr<<"B ";for(int i:B) cerr<<i<<' ';cerr<<'\n';
	return ans=0;
}
void Solve(){
	int i,j;scanf("%d",&n);
	vector<int> A(n),B(n);
	for(i=0;i<n;i++) scanf("%d",&A[i]);
	for(i=0;i<n;i++) scanf("%d",&B[i]);
	puts(dfs(A,B)?"Alice":"Bob");
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

5
1
100
100
2
1 1
1 1
2
1 1
0 1
3
1 1 4
5 1 4
10
116 104 101 114 101 32 97 114 101 32
102 105 118 101 32 99 97 115 101 115

output:


result: