Problem 2269 Picking Game

TimeLimit:3000MS  MemoryLimit:32MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

Fat brother and Maze are playing a kind of special (hentai) game in a weighted tree. In this game, players can pick vertexes in this tree; both of them get 0 point at first. In one player’s turn, he/she can pick a vertex and then sum the weight which is assigned to this vertex to his/her score. They keep doing this one by one which means that after Fat Brother picks his vertex, Maze would picks another one and vice versa. But there is a restriction, when a player picks a vertex; he/she must pick a vertex which is adjacent to the previous one he/she picked in the tree. The picking action is mandatory which means that a player cannot skip his/her own turn at any time. Also, a vertex can be picked at most once which means that if a vertex has been picked by one of the players; no one can pick this vertex in later rounds. Fat Brother always begins the game by picking the vertex 1, and Maze would pick vertex 2 as follow.

The game ends when both players have no vertex to pick. If one of the players has no vertex to pick, the other player can still take actions and skips another player’s turn until both of them have no vertex to pick. The player with the highest points wins this game and they would have a tie if they get the same points.

You can assume that both Fat Brother and Maze are clever enough, in his/her own turn; they always choose the action that benefits him/her most.

Input

The first line of the data is an integer T (1 <= T <= 1000), which is the number of the text cases.

Then T cases follow, each case contains an integer N (2 <= 100000 <= N) indicated the number of the vertexes in this tree. Then a line with N integers indicates the weight of each vertex in this tree. Then goes N-1 lines with two integers x and y (1 <= x, y <= N) each line, which means that there is an edge connected vertex x and vertex y in this tree.

The weights of the vertexes in this tree are positive and no more than 1000.

In 90% of test cases, N <= 50.

Output

For each case, output the case number first, and then output the winner of this game. See the sample output for more details.

SampleInput
5
2
1 2
1 2
2
1 1
1 2
3
3 2 1
1 2
2 3
3
1 3 1
1 2
1 3
5
2 2 1 1 1
1 3
2 3
3 4
2 5
SampleOutput
Case 1: Maze
Case 2: Draw Game
Case 3: Draw Game
Case 4: Maze
Case 5: Fat Brother
Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: