-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
105 lines (81 loc) · 1.63 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
* author: theHoodeyGuy
**/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define nl '\n'
int dp[101][101][2];
int help(int e,int o,int s){
// cout << e <<" "<<o<<" "<<s<<" "<<nl;
if(o == 0){
return 1^s;
}
if(e==0){
if((o+1)%4) return s;
return 1^s;
}
if(dp[e][o][s] != -1) return dp[e][o][s];
int ans;
if(s==0){
//take even
int ans1=1;
if(e >= 2){
ans1 = help(e-2,o,s);
}
ans1 = ans1 and help(e-1,o-1,s);
//take odd
int ans2=1;
if(o >= 2){
ans2 = help(e,o-2,1);
}
ans2 = ans2 and help(e-1,o-1,1);
ans = ans1 or ans2;
}
else{
//take even
int ans1=1;
if(e >=2){
ans1 = help(e-2,o,s);
}
ans1 = ans1 and help(e-1,o-1,s);
//take odd
int ans2=1;
if(o >=2){
ans2 = help(e,o-2,0);
}
ans2 = ans2 and help(e-1,o-1,0);
ans = ans1 or ans2;
}
return dp[e][o][s] = ans;
}
void solve(){
int n;
cin >> n;
vector<int> a(n);
int even = 0,odd = 0;
for(int i=0;i<n;i++) {
cin >> a[i];
if(a[i]&1) odd++;
else even++;
}
memset(dp,-1,sizeof(dp));
cout << (help(even,odd,0) ? "Alice" : "Bob" )<< nl;
}
signed main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
int t ;
cin>>t;
while(t--)
{
solve();
}
// cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
return 0;
}