#P3727. 曼哈顿计划E

    ID: 2689 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>点分治洛谷原创枚举,暴力分治深度优先搜索,DFS

曼哈顿计划E

Description

Aiden tries to hack into dedsec’s system and seize control, but dedsec responds and fights back.

The dedsec network can be regarded as a connected graph with nn nodes and n1n-1 edges (a tree). Each node has a stability value.

Aiden may choose a chain (a simple path) in the network and hack all nodes on that chain (i.e., detach that chain from the tree).

Suppose the chain has length mm (i.e., it contains mm nodes). You will then obtain mm nodes, and the game is played only on these mm nodes.

Aiden and dedsec then start a battle of moves. They take turns. Each move, a player may choose any node with a stability value greater than 00 and perform an operation according to the rules below. After the operation, the stability value of that node must not become less than 00, otherwise the computer will explode. The player who cannot make a move loses.

Because dedsec has the advantage of defense, dedsec moves first.

Although Aiden is skilled at hacking, his phone ran out of battery. He has sent this information to you, hoping you can help save the world. You need to write a program to determine whether there exists a way for Aiden to win. Of course, dedsec’s defense might be flawless, and Aiden may not be able to win at all—in that case, you’ll have to run to the shelter and become a test subject.

Input Format

The input contains multiple test cases. The first line contains an integer TT, the number of test cases.

For each test case:

  • The first line contains an integer nn, the number of nodes.
  • The next n1n-1 lines each contain two integers u,vu, v, indicating an edge between uu and vv in the network.
  • The next line contains nn integers w1,w2,,wnw_1, w_2, \dots, w_n, where wiw_i denotes the stability value of node ii.
  • The next line contains an integer kk, describing the move rules:
    • If k=1k=1, you may decrease the stability by any positive integer.
    • If k=2k=2, the next line contains a positive integer ss, and each move may decrease the stability by a non-negative integer power of ss.
    • If k=3k=3, the next line contains a positive integer ss, and each move may decrease the stability by any integer greater than or equal to ss.
    • If k=4k=4, each move you may either decrease the stability by any positive integer, or split a node with stability at least 22 into two nodes whose stability values sum to the original (for example, split 77 into 3+43+4).
    • If k=5k=5, neither player can make any move.

Output Format

For each test case, output one line:

If there exists a way for you to win, output Mutalisk ride face how to lose?.

If there is no way to win, output The commentary cannot go on!.

1
3
1 2
2 3
1 2 3
1
Mutalisk ride face how to lose?
1
3
1 2
2 3
1 2 4
1
The commentary cannot go on!

Hint

Test point nn \le kk wiw_i \le
11 5050 11 10310^3
22 3×1043 \times 10^4
33 300300 33 10610^6
44 10310^3 44
55 3×1043 \times 10^4 11 10910^9
66 22
77 33
88
99 44
1010

For 100%100\% of the testdata, T5T \le 5.

All inputs are positive integers.

Translated by ChatGPT 5