#P11026. [COTS 2020] 抗疫 Autoritet
[COTS 2020] 抗疫 Autoritet
Background
Translated from Izborne Pripreme 2020 (Croatian IOI/CEOI Team Selection) D2T1。。
Problem Description
There are countries and undirected air routes connecting different countries. Note that there may be multiple routes between the same pair of countries.
During the epidemic, to unite the world to fight against it, we need to connect the world. The world is defined to be connected if and only if any two countries are connected directly or indirectly through air routes.
Let . In one operation:
- Choose any 。
- Let set be the set of countries that country can reach via exactly one air route; let set 。
- For all , delete the air routes connecting and ; for all , add an air route connecting and 。
It can be proven that after adding enough air routes, the world can always be made connected.
You want to make the world connected using the minimum number of operations.
Output:
- The minimum number of operations 。
- Subject to minimizing the number of operations, the number of different operation sequences. You only need the result modulo 。
Two operation sequences are considered different if and only if there exists some such that the country chosen in the -th operation is different in the two sequences.
Input Format
The first line contains two positive integers 。
The next lines each contain two positive integers , describing an air route 。
Output Format
Output two lines, each containing one integer, representing the corresponding answers.
The answer to the second question should be taken modulo 。
6 6
3 4
1 2
2 3
5 4
4 1
4 6
0
1
4 2
1 4
2 3
2
4
8 9
1 4
2 3
6 7
8 5
2 4
7 8
5 6
6 8
4 3
1
5
Hint
Sample Explanation
- Sample : there is a case where no operations are needed。
- Sample : all operation sequences are 。
Scoring
If you answer the first question correctly, you can get of the score.
If you do not plan to answer the second question, you still need to output any integer in , otherwise the score is not guaranteed to be as expected.
Constraints
For of the testdata, it is guaranteed that:
- ;
- 。
| Subtask ID | Score | |
|---|---|---|
Translated by ChatGPT 5