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