#P8347. Tree Component Deletion Game
Tree Component Deletion Game
Tree Component Deletion Game
Two players, Hifuu and Luna, play a game on a tree with n nodes (with n ≥ 2). The players alternate turns, with Hifuu going first. In each turn, the current player chooses a node in the tree and removes that node along with all edges incident to it. This removal splits the tree into one or more connected components. Then, the player selects exactly one of the resulting connected components to keep and discards all the others permanently.
Important: If after a move the remaining component consists of exactly one node, then the move‐maker immediately loses and the other player wins.
Your task is to determine which player has a winning strategy assuming both play optimally. Output Hifuu
if the first player has a forced win; otherwise, output Luna
.
Note: A move is considered valid only if the player can choose a connected component with at least 2 nodes. Moves that leave a single node (even if there are several components, all of which are singletons) cause an immediate loss for the mover.
The game is given as a tree, i.e. a connected acyclic graph, where the nodes are numbered 1 through n and there are exactly n − 1 edges.
inputFormat
The first line contains an integer n (n ≥ 2), the number of nodes in the tree.
The following n − 1 lines each contain two integers u and v (1 ≤ u, v ≤ n) indicating that there is an edge between nodes u and v.
outputFormat
Output a single line: Hifuu
if the first player (Hifuu) can force a win; otherwise, output Luna
.
sample
2
1 2
Luna