#P5830. [ZJOI2016] 随机树生成器
[ZJOI2016] 随机树生成器
Description
Xiao Y recently got a random number generator (random number generator). Xiao Y wants to use this random number generator to generate a tree with nodes. A tree is an undirected connected graph with no cycles.
After some research, Xiao Y found random tree generation methods.
The first method is: first generate a uniformly random permutation of to . Then for every node , add an edge from to , where is a random integer from to .
The second method is: first generate a uniformly random permutation of to . Then for every node , add an edge from to , where is a random integer from to .
The third method is: first start with a graph of vertices with no edges. Then repeatedly generate a pair of vertices uniformly at random. If and are not connected in the current graph, add the edge to the graph. Repeat this process until the graph becomes connected.
The fourth method is: among all different labeled trees on vertices, choose one uniformly at random. Two trees are different if and only if there exists an edge that appears in exactly one of them. For example, and are two different trees.
Xiao Y generated many trees with nodes using these four methods, but she forgot which method generated each tree. Can you help her identify which random method generated each tree?
In this problem, let , meaning every tree generated by Xiao Y has nodes.
Input Format
The first line contains positive integer , indicating the -th set of testdata.
Then an integer , indicating there are trees.
For each tree, there are lines. Each line contains positive integers , indicating there is an edge between node and node in this tree.
Output Format
Output a total of lines. Each line contains a positive integer from to , indicating the random generation method of the corresponding tree.
见附件
见附件
Hint
For all testdata, it is guaranteed that the input trees are generated by the four methods above.
Each test point satisfies the following rules.
| Test Point | Rule | |
|---|---|---|
| 1 | Only methods will appear. | |
| 2 | Only methods will appear. | |
| 3 | Only methods will appear. | |
| 4 | None. | |
| 5 |
For each test point, it is guaranteed that each possible appearing generation method appears exactly times.
Scoring
For each test point, there are scoring parameters .
If the number of wrong answers in your output is , then you will get a score of , where is the largest integer satisfying . If , then you will get points.
If the output format is abnormal, you will also get points. Please make sure your output has exactly lines, and each line is an integer from to .
For the specific scoring parameters of each test point, see scores in the additional files.
Translated by ChatGPT 5
京公网安备 11011102002149号