Stone Duel
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Time Limit: 1.0 s
Memory Limit: 256.0 MB
Description
Hridoy and Kamona, who are friends, are engaged in a competitive game called Stone Duel. The game begins with \(N\) stacks of stones, where each stack has a certain initial number of stones given by an array \(𝐴\). The goal is straightforward: the player who removes the last stone wins the game.
Roles:
- Hridoy: The first player who makes the initial move.
- Kamona: The second player who takes the next turn and alternates thereafter.
On each turn, a player must choose a single stack and either:
- Remove one or more stones from that stack, or
- Add one or more stones to that stack (note: each stack can only receive additional stones up to a maximum of \(K\) times for the entire game).
At least one stone must be added or removed on each turn. The game concludes when the last stone is removed, and the player making this move is declared the winner.
Determine who will be the winner if both the players play with optimal strategy.
Input
First line contains an integer \(T\) : number of testcases.
The first line of each testcase contains two integers \(N\) and \(K\) : the number of stacks and the maximum number of stones that can be added to any stack.
The second line of each testcase contains \(N\) integers \(A_1, A_2, A_3, ..., A_n\).
\(1 \le T , N , K \le 1000\)
\(1 \le A_i \le 10^5\)
Output
Print the name of the winner.
Sample
Input | Output |
---|---|
|
|
Sylhet ICPC 2024 Collaborative Challenge: Episode 2
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 9
- Start at
- 2024-10-30 08:45
- End at
- 2024-10-30 12:45
- Duration
- 4.0 hour(s)
- Host
- Partic.
- 18