Rook, Bishop, King, Knight, and Palace Game
Time limit0.5sMemory limit512 MB
Two players take turns moving chess pieces toward the lower left on a huge board, and the task is to find who wins with optimal play.
- Level
Hard9 of 10
- Topics
- Game theory, Math, Implementation
- Solved
- No attempts yet
Problem
Today, Cubelover and I are playing a game with rooks, bishops, kings, knights, and palaces.
N chess pieces are placed on a chessboard of size . The pieces used in this game are rooks, bishops, kings, knights, and palaces. The palace is a chess piece that Koosaga created in problem 16878. A palace can move both like a rook and like a king. In other words, it can move to any square in the same row or column, or to one of the four adjacent squares or four diagonal squares.
Koosaga and Cubelover take turns, and each turn goes as follows.
- Choose one piece on the board and move it once toward the lower left. That is, the move must decrease the Manhattan distance, and neither coordinate may increase.
A player who cannot move any piece loses.
When both players play optimally, determine who wins. Koosaga moves first. Two or more pieces may occupy the same square.
The lower left square has coordinates (0, 0), and the upper right square has coordinates (, ).
Input
The first line contains the number of pieces (). Each of the next lines contains the coordinates , () and the type of one piece.
is one of R, B, K, N, or P, which mean rook, bishop, king, knight, and palace, respectively.
Output
Print "koosaga" if Koosaga wins, and "cubelover" if Cubelover wins.