Palace Game
Time limit0.5sMemory limit512 MB
Given N palaces at coordinates on a 3000x3000 board, players alternately move one palace toward the lower-left (decreasing Manhattan distance) via rook or king moves, and the player unable to move loses.
- Level
Medium7 of 10
- Topics
- Game theory, Math, Implementation
- Solved
- No attempts yet
Problem
The palace is a chess piece that koosaga invented in Problem 16878. A palace can move both the way a rook moves and the way a king moves. That is, it can move to a square in the same row or column, or to one of the four adjacent squares or the four diagonal squares.
Today, we will play a game with palaces together with cubelover.
N palaces are placed on a 3000×3000 chessboard. Koosaga and cubelover take turns, and each turn goes as follows.
- Choose one palace on the chessboard and move it once toward the lower left. That is, its "Manhattan distance" from the bottom-left square must decrease.
The player who can no longer move a palace loses the game.
Write a program that determines who wins when both players play optimally. Koosaga moves first, and two or more palaces may occupy the same square at the same time.
The bottom-left square has coordinates (0, 0), and the top-right square has coordinates (2999, 2999).
Input
The first line gives the number of palaces N (1 ≤ N ≤ 300,000). Each of the next N lines gives the coordinates x, y of one palace (0 ≤ x, y < 3000).
Output
Print "koosaga" if koosaga wins the game, and "cubelover" if cubelover wins.