当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6741:MUV LUV UNLIMITED

题目描述
There are few entertainments in United Nations 11th Force, Pacific Theater, Yokohama Base, the only pastime for squad 207 is gathering in PX to play games after supper. However, whatever they play, Shirogane Takeru is always the loser. So he decides to use the game theory knowledge from another world to become the winner. According to the knowledge he has learnt, Takeru introduces his army friends a game:
Given a rooted tree of size n, whose root is vertex 1. Two players do operations on the tree alternately. In each operation, a player should choose several (at least one) leaf vertices (which have no children vertices) and remove them from the tree. As can be seen, there might be some new leaf vertices after one operation. The player who cannot make a move in his/her turn loses the game.
But unfortunately, Takeru doesn’t master the knowledge skillfully, so he has no idea whether the first player will win if the two players are playing optimally. Please help him determine that.
Assume that the two players are playing optimally to make themselves win, print “Takeru” in a single line if the first player will win, or print “Meiya” otherwise.
输入解释
The first line contains one positive integer T, denoting the number of test cases.
For each test case:
The first line contains one positive integer n (2 ≤ n ≤ $10^6$), denoting the size of the given tree.
The next line contains n 1 positive integers pi (1 ≤ pi ≤ n), where i-th integer denotes the parent vectex of vectex i + 1.
It is guaranteed that the sum of n among all cases in one test file does not exceed $10^6$.
输出解释
Output T lines each contains a string “Takeru” or “Meiya”, denoting the answer to corresponding test case.
输入样例
2
3
1 1
4
1 2 3
输出样例
Takeru
Meiya

提示
For the first case, the first player can remove vertex 3 firstly. As a result, the second player has no
choice but to remove vertex 2. Finally, the first player removes vertex 1 and becomes the winner.
For the second case, the two players can only remove exactly one vertex in each operation alternately.
As can be seen, the winner, who removes vertex 1, will be the second player.
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 642ccpcQHD

源链接: HDU-6741

最后修改于 2020-10-25T23:33:57+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 131072/131072K(Java/Others)