#P4581. [BJOI2014] 想法
[BJOI2014] 想法
Description
Xiao Qiang and Amiba are good friends. Xiao Qiang wants to prepare a set of problems.
His problems are known for broad scope (biased), deep probing (quirky), and high difficulty (hard). To prepare problems, he has collected essentially different ideas, and each idea forms a problem. However, he feels that using these problems to test contestants would make the contest too extreme, so he asks Amiba to help adjust his problems.
Amiba points out a general method called “combination” to make an exam’s coverage as comprehensive as possible. If two problems and are combined, then the set of ideas involved in the resulting problem is the union of the sets of ideas involved in and . Moreover, problems can be combined repeatedly.
For example, suppose Xiao Qiang currently has three ideas , corresponding to problems respectively:
- Xiao Qiang combines and to get . The set of ideas involved in is .
- Xiao Qiang combines and to get . The set of ideas involved in is .
- Xiao Qiang combines and to get . The set of ideas involved in is .
Now, Xiao Qiang tells you how each problem was formed by combination. Your task is to answer how large the set of ideas involved in each problem is.
However, this problem is hard. So you only need to answer fairly accurately with a relatively high probability.
Input Format
The first line contains two integers , denoting the number of Xiao Qiang’s problems and the number of ideas, respectively.
Then follow lines, each containing two integers, indicating which two problems were combined to form each combined problem.
The ideas correspond to problems numbered through . After that, the first combined problem is numbered , the second combined problem is numbered , and so on.
Output Format
This problem uses Special Judge.
Output lines. Each line contains one integer, which is the number of ideas involved in each combined problem.
6 3
1 2
2 3
4 5
2
2
3
Hint
Constraints: For of the testdata, , .
If at least of your lines have absolute error within of the correct answers, you will receive points.
“Error within ” means: if the correct answer is , then your answer falling in the closed interval counts as within error.
Translated by ChatGPT 5
京公网安备 11011102002149号