| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 71 | 17 | 5 | 20.000% |
Bessie has a new two-person game: TwoFour. She has N (3 ≤ N ≤ 30) piles, each with a number of balls (0 ≤ nballs ≤ 4). The total number of balls is 2*N.
To play, the players alternate taking turns, each of which comprises a single valid move. A valid move consists of the following actions:
The game ends when no more moves can be made. In fact, at the end of the game, every pile will contain exactly two balls.
The winner of the game is the player who 'owns' most piles. Ties are possible. A player 'owns' a pile if the pile has two balls and this resulted from the player's most recent move to or form that pile. Consider these examples:
Ownership can change. Consider that a player owns a pile with two balls. If the other chooses a pile with four balls and moves a ball to the pile with two, then the pile is no longer owned by anyone.
If, at the beginning of the game, some piles have two balls, then the piles are equally distributed among the two players with any extra pile being owned by player two.
Player 1 is the one who makes the first move.
Your program must decide, for an initial game state, who will be the winner or if the game ends in a tie when both players play as well as they can. Your program will be presented with G (1 ≤ G ≤ 1000) game states.
5 4 0 3 4 1 2 2 2 2 2 2 1 1 2 2 4 4 3 2 1 0
1 2 1 1