QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#344876#3811. Game of CardsPetroTarnavskyi#AC ✓22ms3840kbC++201.0kb2024-03-05 17:09:332024-03-05 17:09:33

Judging History

This is the latest submission verdict.

  • [2024-03-05 17:09:33]
  • Judged
  • Verdict: AC
  • Time: 22ms
  • Memory: 3840kb
  • [2024-03-05 17:09:33]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first 
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

int solve(int k)
{
	int n;
	cin >> n;
	VI a(n);
	VI dp(n + 1);
	dp[0] = 0;
	
	FOR(i, 0, n)
	{
		cin >> a[i];
		VI vals;
		FOR(j, 0, min(k, i) + 1)
		{
			int pos = i - j - a[i - j] + 1;
			if(pos >= 0)
				vals.PB(dp[pos]);
		}
		sort(ALL(vals));
		int me = 0;
		FOR(j, 0, SZ(vals))
			if(vals[j] == me)
				me++;
		
		dp[i + 1] = me;
	}
	return dp[n];
}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	int val = 0;
	FOR(i, 0, n)
		val ^= solve(k);
	
	if(val == 0)
		cout << "Bob will win.\n";
	else
		cout << "Alice can win.\n";
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3540kb

input:

2 2
1 3
2 1 1

output:

Alice can win.

result:

ok single line: 'Alice can win.'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

2 10
1000 10 1 5 8 10 6 4 7 2 6 2 4 7 4 4 3 2 8 5 2 5 7 10 3 2 5 8 4 6 9 5 3 7 6 9 6 6 4 5 10 3 6 10 9 5 5 1 4 8 3 1 10 6 3 4 1 10 8 6 9 3 3 10 3 7 8 9 7 3 6 9 9 3 7 10 2 5 2 9 1 5 7 10 4 9 8 10 5 6 1 9 9 1 7 2 6 4 1 8 7 5 6 2 5 5 4 9 3 7 7 10 5 2 4 8 8 7 7 2 2 4 8 1 3 2 7 9 10 1 6 7 1 5 2 3 10 7 4 ...

output:

Bob will win.

result:

ok single line: 'Bob will win.'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

10 1
1000 3 5 4 3 8 4 4 4 6 8 2 8 6 2 5 1 5 10 5 10 7 8 10 4 2 3 8 7 8 2 9 8 5 7 10 2 7 8 9 8 1 1 2 3 9 10 5 7 3 4 2 3 4 1 7 5 7 2 5 8 3 4 7 1 5 8 4 5 1 10 5 6 7 5 7 3 10 6 6 4 4 2 6 6 3 3 4 3 6 7 10 5 4 8 4 7 6 2 10 9 2 4 3 10 2 7 1 4 6 6 7 1 9 1 3 4 4 3 5 2 10 3 4 2 4 4 8 5 2 2 3 1 5 4 3 9 1 8 9 9...

output:

Alice can win.

result:

ok single line: 'Alice can win.'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3828kb

input:

11 1
1000 3 5 4 3 8 4 4 4 6 8 2 8 6 2 5 1 5 10 5 10 7 8 10 4 2 3 8 7 8 2 9 8 5 7 10 2 7 8 9 8 1 1 2 3 9 10 5 7 3 4 2 3 4 1 7 5 7 2 5 8 3 4 7 1 5 8 4 5 1 10 5 6 7 5 7 3 10 6 6 4 4 2 6 6 3 3 4 3 6 7 10 5 4 8 4 7 6 2 10 9 2 4 3 10 2 7 1 4 6 6 7 1 9 1 3 4 4 3 5 2 10 3 4 2 4 4 8 5 2 2 3 1 5 4 3 9 1 8 9 9...

output:

Bob will win.

result:

ok single line: 'Bob will win.'

Test #5:

score: 0
Accepted
time: 21ms
memory: 3560kb

input:

99 10
1000 5 6 1 4 8 9 4 2 10 9 7 9 9 4 10 6 8 9 4 9 6 4 1 8 5 5 1 2 3 5 3 1 6 1 4 3 8 5 8 5 8 5 5 7 1 7 5 3 9 4 4 4 9 6 7 6 5 9 1 7 10 2 5 1 5 8 5 1 1 4 8 3 3 4 7 5 7 4 9 6 3 10 2 1 6 10 2 10 10 1 7 4 1 2 8 7 10 9 1 2 3 7 10 3 10 1 4 7 5 1 2 3 3 4 6 10 3 2 1 5 9 4 3 5 3 5 2 3 1 5 8 2 8 10 7 2 10 5 ...

output:

Alice can win.

result:

ok single line: 'Alice can win.'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3492kb

input:

4 2
20 9 4 9 6 4 8 3 2 8 5 8 4 9 7 7 6 7 8 6 7
20 8 1 5 2 6 3 2 8 8 10 6 3 10 5 5 7 5 6 9 3
20 2 6 10 7 4 7 5 8 1 3 7 7 7 10 6 2 7 7 1 2
20 5 4 9 10 9 1 5 8 9 1 7 3 6 9 8 3 4 5 4 6

output:

Alice can win.

result:

ok single line: 'Alice can win.'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3780kb

input:

5 2
20 9 4 9 6 4 8 3 2 8 5 8 4 9 7 7 6 7 8 6 7
20 8 1 5 2 6 3 2 8 8 10 6 3 10 5 5 7 5 6 9 3
20 2 6 10 7 4 7 5 8 1 3 7 7 7 10 6 2 7 7 1 2
20 5 4 9 10 9 1 5 8 9 1 7 3 6 9 8 3 4 5 4 6
4 4 3 2 1

output:

Bob will win.

result:

ok single line: 'Bob will win.'

Test #8:

score: 0
Accepted
time: 22ms
memory: 3560kb

input:

99 10
1000 2 9 8 3 5 5 7 8 1 1 9 5 8 1 5 8 3 10 10 1 1 6 10 4 3 5 1 3 5 5 3 3 3 5 3 1 9 6 7 2 10 9 2 4 8 8 10 5 9 7 4 6 9 9 6 6 1 3 8 5 2 6 8 7 4 5 6 8 6 4 5 1 1 8 10 6 4 2 6 10 8 6 9 3 6 10 6 5 3 6 10 1 8 9 9 8 9 6 6 5 1 9 6 2 6 5 4 4 6 7 7 5 1 3 2 6 9 8 8 9 3 9 7 1 1 1 8 3 2 7 4 1 2 6 2 3 8 5 4 5 ...

output:

Alice can win.

result:

ok single line: 'Alice can win.'

Test #9:

score: 0
Accepted
time: 21ms
memory: 3600kb

input:

100 10
1000 2 9 8 3 5 5 7 8 1 1 9 5 8 1 5 8 3 10 10 1 1 6 10 4 3 5 1 3 5 5 3 3 3 5 3 1 9 6 7 2 10 9 2 4 8 8 10 5 9 7 4 6 9 9 6 6 1 3 8 5 2 6 8 7 4 5 6 8 6 4 5 1 1 8 10 6 4 2 6 10 8 6 9 3 6 10 6 5 3 6 10 1 8 9 9 8 9 6 6 5 1 9 6 2 6 5 4 4 6 7 7 5 1 3 2 6 9 8 8 9 3 9 7 1 1 1 8 3 2 7 4 1 2 6 2 3 8 5 4 5...

output:

Bob will win.

result:

ok single line: 'Bob will win.'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

2 1
1 1
1 1

output:

Bob will win.

result:

ok single line: 'Bob will win.'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

2 2
5 3 2 1 2 1
5 5 4 3 2 1

output:

Alice can win.

result:

ok single line: 'Alice can win.'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

4 1
4 1 1 1 1
6 2 1 2 1 2 1
4 1 1 1 1
6 2 1 2 1 2 1

output:

Bob will win.

result:

ok single line: 'Bob will win.'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

2 1
3 2 1 2
3 2 1 2

output:

Bob will win.

result:

ok single line: 'Bob will win.'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

2 1
1 1
3 1 2 1

output:

Alice can win.

result:

ok single line: 'Alice can win.'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

3 2
4 4 7 1 8
4 4 8 4 6
4 10 1 6 1

output:

Alice can win.

result:

ok single line: 'Alice can win.'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

3 3
4 5 9 8 1
4 1 10 4 4
4 5 9 10 4

output:

Alice can win.

result:

ok single line: 'Alice can win.'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

1 10
1000 10 1 5 8 10 6 4 7 2 6 2 4 7 4 4 3 2 8 5 2 5 7 10 3 2 5 8 4 6 9 5 3 7 6 9 6 6 4 5 10 3 6 10 9 5 5 1 4 8 3 1 10 6 3 4 1 10 8 6 9 3 3 10 3 7 8 9 7 3 6 9 9 3 7 10 2 5 2 9 1 5 7 10 4 9 8 10 5 6 1 9 9 1 7 2 6 4 1 8 7 5 6 2 5 5 4 9 3 7 7 10 5 2 4 8 8 7 7 2 2 4 8 1 3 2 7 9 10 1 6 7 1 5 2 3 10 7 4 ...

output:

Alice can win.

result:

ok single line: 'Alice can win.'