This is the medium version of the problem. The difference in this version is that $$$t=1$$$ and we work on trees.
Ron and Hermione are playing a game on a tree of $$$n$$$ nodes that are initially inactive. The game consists of $$$t$$$ rounds, each of which starts with a stone on exactly one node, which is considered as activated. A move consists of picking an inactive neighbor of the node with a stone on it and moving the stone there (thus activating this neighbor). Ron makes the first move, after which he alternates with Hermione until no valid move is available. The player that cannot make a move loses the round. If both players play optimally, who wins each round of this game?
Note that all the rounds are played with the same tree; only the starting node changes. Moreover, after each round, all active nodes are considered inactive again.
The first line contains integers $$$n$$$ ($$$2 \leq n \leq 2\times 10^5$$$), $$$t$$$ ($$$t=1$$$), the number of nodes in the tree and the number of rounds, respectively.
The next $$$n-1$$$ lines contain two integers $$$1 \leq u, v \leq n$$$ each, corresponding to an edge of the tree.
The next line contains $$$t$$$ integers $$$1 \leq u_1 , \dots, u_t \leq n$$$, corresponding to the node where the stone is initially put.
The output consists of $$$t=1$$$ line which is either "Ron" or "Hermione".
5 11 21 33 43 51
Ron
Название |
---|