The 7th(2012) ACM Programming Contest of HUST - Onsite Contest(Semilive)
From: 2012-12-16 12:10:00
To: 2012-12-16 17:10:00
Now: 2017-09-20 01:10:27
F - A new tree game
Time Limit: 1s
Memory Limit: 128MB
Submissions: 147 Solved: 42
- tclsm and littleSheep want to play an interesting game on a tree.Given is a tree on N vertices, The vertices are numbered from 0 to N - 1. vertex 0 represents the root. There are N-1 edges. Players alternate in making moves, tclsm moves first. A move consists of two steps. In the first step the player selects an edge and cuts it from the tree. In the second step he/she removes all the edges that are no longer connected to the root. The player who has no edge to remove loses.You know this game is so easy for GodSheep so tclsm wants to Strengthen the game.So tclsm defines a K represents an edge need to cut K times before breaking.
You may assume that both tclsm and littleSheep play optimally.
- The first line of the input file contains an integer T (T<=50) specifying the number of test cases.
Each test case begins with a line containing an integer N (1<=N<=10^4), the number of vertices,The following N-1 lines each contain two integers I , J(0<=I, J<N), which means I is connected with J. You can assume that there are no loops in the tree.And following a line contain an integer Q (1<=Q<=10^4), the number of querys.The following Q lines each contain an integer K(1<=K<=Q), which means Edges's weight is K.
- For each query, output a single line containing the name of the player who will win the game.3
- Sample Input
- Sample Output
- The 7th(2012) ACM Programming Contest of HUST
Problem Setter: Shunmin Li