-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew.cpp
More file actions
61 lines (55 loc) · 1.17 KB
/
Copy pathnew.cpp
File metadata and controls
61 lines (55 loc) · 1.17 KB
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
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
vector<bool> canWin(n, false);
for (int start = 0; start < n; start++)
{
vector<int> b = a;
int total = 0;
for (int x : b)
total += x;
int cur = start;
int winner = -1;
while (total > 0)
{
if (b[cur] > 0)
{
b[cur]--;
total--;
if (total == 0)
{
winner = cur;
break;
}
}
cur = (cur + 1) % n;
}
if (winner != -1)
{
canWin[winner] = true;
}
}
int ans = 0;
for (bool w : canWin)
{
if (w)
ans++;
}
cout << ans << endl;
}
return 0;
}