Stone Duel
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 |
---|---|
|
|
Information
- ID
- 1118
- Difficulty
- 6
- Category
- Games Click to Show
- Tags
- # Submissions
- 17
- Accepted
- 10
- Accepted Ratio
- 59%
- Uploaded By
Related
In following contests: