-
Notifications
You must be signed in to change notification settings - Fork 0
/
A. Everything Nim.cpp
129 lines (108 loc) · 1.95 KB
/
A. Everything Nim.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include <bits/stdc++.h>
#define int long long
#define vi vector<int>
#define vb vector<bool>
#define readInput(a) \
for (auto &i : a) \
cin >> i
#define printOutput(a) \
for (auto &i : a) \
cout << i << " "
#define endLine "\n"
#define space << " " <<
#define pushBack pb
#define allElements(a) a.begin(), a.end()
#define reverseAll(a) a.rbegin(), a.rend()
const int N = 1e6 + 2;
const int MOD = 1e9 + 7;
const int INF = LLONG_MAX;
using namespace std;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--)
{
// int n;
// cin >> n;
// int a[n];
// for (int i = 0; i < n; i++)
// cin >> a[i];
// sort(a, a + n);
// int mex = 1;
// for (int i = 0; i < n; i++)
// if (a[i] == mex)
// mex++;
// cout<<mex<<endl;
// if (mex == a[n - 1] + 1)
// cout << (mex & 1 ? "Bob\n" : "Alice\n");
// else
// cout << (mex & 1 ? "Alice\n" : "Bob\n");
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
int sub = 0;
int winner = 0;
for (int i = 0; i < n; i++)
{
a[i] -= sub;
if (a[i] == 1)
{
winner ^= 1;
sub += a[i];
}
else if (a[i] > 1)
{
winner ^= 1;
break;
}
}
if (winner)
cout << "Alice\n";
else
cout << "Bob\n";
}
}
/*
8
5 7 2 9 6 3 3 2
3 5 0 7 4 1 1 0 A
1 4 0 6 3 0 0 0 B
0 3 0 5 2 0 0 0 A
0 1 0 3 0 0 0 0 B
0 0 0 2 0 0 0 0 A
0 0 0 0 0 0 0 0 B
/////////////////////////////
1 7 A
0 6 B
0 0 A
//////////////////
2 1 3 4 2 4 A
1 0 2 3 1 3 B
0 0 1 2 0 2 A
0 0 0 1 0 1 B
0 0 0 0 0 0 A
//////////////////////
int n;
cin>>n;
set<int> s;
for(int x;n--;) cin>>x,s.insert(x);
int op=0,l=0;
for(int x:s){
op^=1;
if(x-l>1) break;
l=x;
}
cout<<(op?"Alice\n":"Bob\n");
///////////////////////////
1 2 2 3 4 4
0 1 1 2 3 3
0 0 0 1 2 2
0 0 0 0 1 1
0 0 0 0 0 0
*/