Odd-Even Game
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
Roy and Hridoy are playing an interesting game. There are N numbers on the board.
In each turn, one of them must remove exactly one number from the board. They remove elements until there is no element remaining on the board.
But they want to make the game more interesting: they cannot select two consecutive moves with the same parity. That means if Roy's previous move removes an odd number, his current move must remove an even number, or he loses the game. The same goes for Hridoy: If his previous move removes an even number, his next move must remove an odd number, or he loses the game. Roy starts the first turn, and they can select any parity for their first move.
If they play optimally, who will win?
Note : At any moment, those who cannot make a move lose the game. And if there are no numbers on the board, those who make the last move (\(N_{th}\) move) consider him as the winner.
Input
First line T, the number of test cases.
In each test case, first line N the length of the array.
Second line, an array \(A[]\) with exactly N elements.
\(1<=T<=10^4\)
\(1<=N<=10^5\)
\(1<=A[]<=10^5\)
Sum of N overall test case doesn't exceed \(2 * 10^5\).
Output
In each test case, print Roy if Roy wins the game, otherwise print Hridoy.
Sample
Input | Output |
---|---|
|
|
First test case,
1st move Roy choose : 2, and remove it from the board. Now \(A[]\)={1,3}.
2nd move Hridoy choose : 3, and remove it from the board. Now \(A[]\)= {1}.
3rd move Roy choose : 1, (becuase his previous move was an even number, so he must choose an odd number in this move) and remove it from the board. Now \(A[]\)={}.
4th move Hridoy : He cannot choose any number, because board is empty. So he lost the game.
Brain Booster #6
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 9
- Start at
- 2024-10-03 15:30
- End at
- 2024-10-03 18:00
- Duration
- 2.5 hour(s)
- Host
- Partic.
- 151