#P7729. 交通运输(Wormhole Transportation)
交通运输(Wormhole Transportation)
Description
There are bases on Eternal Continent, numbered .
Now there are transportation tasks. The -th task is: transport goods from base to base .
However, transportation after the disaster is not well developed, so you decide to use wormholes. You can build a wormhole between any two different bases . Transporting goods from one end of the wormhole to the other end only takes unit of time.
Also, transportation is bidirectional. That is, if you build a wormhole connecting bases and , then goods can be transported from base to base , and also from base to base .
But building wormholes is expensive. You decide to build exactly wormholes, and no two wormholes may connect the exact same pair of bases.
You want to know, among all construction plans, what is the minimum possible total time spent for the transportation tasks. In addition, under the condition that this total time is minimized, how many different wormhole construction plans are there.
Since the answer to the second question may be very large, you only need to output it modulo .
Input Format
The first line contains three integers , where is the subtask ID. For the samples, .
The next lines each contain two integers .
Output Format
The first line contains one integer, the minimum total time spent for the transportation tasks.
The second line contains one integer, the number of wormhole construction plans modulo .
3 3 0
1 2
2 3
3 1
4
3
5 6 0
1 2
2 3
1 4
4 3
1 5
5 3
8
30
Hint
[Sample 1 Explanation]
There are three construction plans.
One plan is to build wormholes between cities and between cities . Then the time for the first two tasks is , and the time for the last task is .
The other two plans are: build wormholes between cities and , or build wormholes between cities and .
[Constraints]
For all data, , , , and .
It is guaranteed that all unordered pairs are pairwise distinct, and that there exists at least one valid wormhole construction plan.
| Subtask ID | Score | Special Constraints | Partial Score | |
|---|---|---|---|---|
| None | ||||
| , and | ||||
| The graph formed by treating all as undirected edges is a cactus forest | ||||
| The graph formed by treating all as undirected edges is an almond | ||||
| None |
Cactus forest: an undirected graph in which each edge belongs to at most one simple cycle.
Almond: a connected undirected graph in which there are exactly two vertices with degree greater than , all other vertices have degree exactly , and all cycles pass through the two vertices with degree greater than .
If for all test points of a subtask, your answer to the first question is all correct, but your answer to the second question is not all correct, you will receive the partial score for this subtask.
Translated by ChatGPT 5
京公网安备 11011102002149号