311321: CF1970C1. Game on Tree (Easy)

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C1. Game on Tree (Easy)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

This is the easy version of the problem. The difference in this version is that $t=1$ and we work on an array-like tree.

Ron and Hermione are playing a game on a tree of $n$ nodes that are initially inactive. This tree is special because it has exactly two leaves. It can thus be seen as an array. 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.

Input

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. It is guaranteed that the tree has exactly two leaves.

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.

Output

The output consists of $t=1$ line which is either "Ron" or "Hermione".

ExamplesInput
3 1
2 3
3 1
3
Output
Ron
Input
5 1
1 2
2 3
3 4
4 5
5
Output
Hermione

Output

题目大意:
这是一个关于在树形结构上进行的游戏的题目。在这个游戏中,Ron和Hermione在一棵有n个节点的树上玩游戏,这些节点最初都是非激活状态。树的特殊之处在于它恰好有两个叶子节点,因此它可以被视为一个数组。游戏由t轮组成,每一轮开始时,恰好有一个节点上有一块石头,这个节点被视为激活状态。一步移动包括挑选一个带有石头节点的非激活邻居,并将石头移动到那里(从而激活这个邻居)。Ron先走,之后他轮流和Hermione进行,直到没有有效的移动为止。无法进行移动的玩家输掉这一轮。如果两位玩家都采取最佳策略,谁会赢得每一轮游戏?

输入数据格式:
第一行包含两个整数n(2≤n≤2×10^5)和t(t=1),分别表示树中的节点数和轮数。
接下来的n-1行,每行包含两个整数1≤u,v≤n,对应树的一条边。保证这棵树恰好有两个叶子节点。
最后一行包含t个整数1≤u1,…,ut≤n,对应石头最初放置的节点。

输出数据格式:
输出由t=1行组成,这行是“Ron”或“Hermione”,表示最终获胜的玩家。

请注意,所有的轮都是在同一棵树上进行的;只有起始节点会改变。此外,在每一轮之后,所有激活的节点都会被视为非激活状态。题目大意: 这是一个关于在树形结构上进行的游戏的题目。在这个游戏中,Ron和Hermione在一棵有n个节点的树上玩游戏,这些节点最初都是非激活状态。树的特殊之处在于它恰好有两个叶子节点,因此它可以被视为一个数组。游戏由t轮组成,每一轮开始时,恰好有一个节点上有一块石头,这个节点被视为激活状态。一步移动包括挑选一个带有石头节点的非激活邻居,并将石头移动到那里(从而激活这个邻居)。Ron先走,之后他轮流和Hermione进行,直到没有有效的移动为止。无法进行移动的玩家输掉这一轮。如果两位玩家都采取最佳策略,谁会赢得每一轮游戏? 输入数据格式: 第一行包含两个整数n(2≤n≤2×10^5)和t(t=1),分别表示树中的节点数和轮数。 接下来的n-1行,每行包含两个整数1≤u,v≤n,对应树的一条边。保证这棵树恰好有两个叶子节点。 最后一行包含t个整数1≤u1,…,ut≤n,对应石头最初放置的节点。 输出数据格式: 输出由t=1行组成,这行是“Ron”或“Hermione”,表示最终获胜的玩家。 请注意,所有的轮都是在同一棵树上进行的;只有起始节点会改变。此外,在每一轮之后,所有激活的节点都会被视为非激活状态。

加入题单

上一题 下一题 算法标签: