#P8347. 「Wdoi-6」另一侧的月
「Wdoi-6」另一侧的月
Description
Brief statement
You are given a tree with nodes (guaranteed ). Hifuu and Luna take turns making moves, with Hifuu moving first. In each turn, the player chooses a node, deletes "that node" and "all edges connected to that node", which splits the tree into several connected components. The player then keeps exactly one of these connected components. If after the turn ends there is only one node left, then the player who made that move loses and the other player wins. Determine who has a winning strategy.
Original statement
However, the Lunar Capital is protected by a barrier, which means that if Renko and Maribel want to travel to the Moon by some method, they must break through this barrier.
The barrier of the Lunar Capital is a connected structure consisting of nodes and psychic energy transmission channels, where the nodes are numbered from . The barrier has a central control system to guard against outsiders breaking into the barrier and reaching the Lunar Capital. Renko and Maribel need to interact with this control system in order to enter the Lunar Capital.
More specifically, Renko and Maribel and the central control system take turns operating, and Renko and Maribel move first. On each move, the player may choose any node on the barrier, cut off all psychic energy transmission channels connected to this node, and discard this node. This means the barrier will be split into several groups of nodes: there are no psychic energy transmission channels between different groups, while nodes within a group remain connected by these channels. Among these node groups, the player may choose to keep one group of nodes and discard all other nodes, i.e., those discarded nodes can no longer be operated on in the future.
Under these rules, if after the move ends only one node remains, then the player who made that move loses and the other player wins. Now Renko and Maribel want to know: under these rules, do they have a strategy that guarantees they can reach the Lunar Capital?
Input Format
This problem contains multiple test cases. The first line contains a positive integer , the number of test cases. For each test case:
- The first line contains a positive integer .
- The next lines each contain two positive integers , representing a bidirectional psychic energy transmission channel connecting node and node .
Output Format
For each test case, output whether Renko and Maribel can reach the Lunar Capital. Specifically, if they have a strategy that guarantees reaching the Lunar Capital, output ; otherwise output .
1
5
2 4
1 2
3 1
5 2
Hifuu
1
11
1 2
1 3
1 4
2 5
2 6
4 7
5 8
5 9
9 10
9 11
Hifuu
1
2
1 2
Luna
Hint
Sample explanation
Sample #1

Figure shows the barrier. Figure and Figure show one possible winning strategy for Renko and Maribel: choose node , then keep the connected component containing . Then no matter whether the central control system chooses node or node , it must lose.
Sample #2

Constraints
This problem uses bundled tests.
$$\def\arraystretch{1.5} \begin{array}{|c|c|c|c|c|}\hline \textbf{Subtask} & \textbf{\textsf{分值}} & \bm{n\le } & \textbf{\textsf{特殊性质}} & \textbf{Subtask \textsf{依赖}}\cr\hline 1 & 15 & 8 & - & - \cr\hline 2 & 20 & 10^5 & \mathbf{A} & -\cr\hline 3 & 20 & 10^5 & \mathbf{B} & - \cr\hline 4 & 15 & 10^3 & - & 1 \cr\hline 5 & 30 & 10^5 & - & 2,3,4 \cr\hline \end{array}$$- Special property : it is guaranteed that there exists a node whose degree is .
- Special property : it is guaranteed that , and the tree is a perfect binary tree.
For of the testdata: , , and the input forms a tree.
Translated by ChatGPT 5
京公网安备 11011102002149号