-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path1020 - A childhood game.cpp
73 lines (61 loc) · 1.15 KB
/
1020 - A childhood game.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
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sl(n) scanf("%lld", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n); getchar();
int al[3000000];
int bo[3000000];
int alice(ll n)
{
if (n == 1)
return -1;
if (al[n] == 0)
{
if (alice(n-1) == -1 || alice(n-2) == -1)
{
al[n] = 1;
}
}
al[n] = -1;
return al[n];
}
int bob(ll n)
{
if (n == 1)
return -1;
if (bo[n] == 0)
{
if (bob(n-1) == -1 || bob(n-2) == -1)
{
bo[n] = 1;
}
}
bo[n] = -1;
return bo[n];
}
int main ()
{
freopen("outl.txt", "w", stdout);
ll cs, t, i, j, k, n, x, y, ans, q;
string s;
sl(t);
for (cs = 1; cs <= t; cs++)
{
cin >> n >> s;
printf("Case %lld: ", cs);
if (s == "Alice")
{
if (alice(n) == 1)
cout << "Alice" << endl;
else cout << "Bob" << endl;
}
else
{
if (bob(n) == 1)
cout << "Bob" << endl;
else cout << "Alice" << endl;
}
}
return 0;
}