#P9167. [省选联考 2023] 城市建造
[省选联考 2023] 城市建造
Problem Description
In this country, there are cities. At the beginning, there are some bidirectional roads between the cities, which makes these cities form connected components. In particular, for any two components, the absolute difference of their sizes is at most . To make city construction and development easier, among the cities, some cities built at least one additional bidirectional road among these cities, so that all cities become connected.
Now all roads after adding are known. You need to determine which sets of bidirectional roads could possibly be the roads added later. Output the result modulo .
That is, given an undirected connected graph with vertices and edges, ask how many subgraphs satisfy , and has exactly connected components, and the size difference between any two connected components is at most . It is guaranteed that . Output the result modulo .
Input Format
The first line contains three positive integers , representing the number of cities, the number of roads after construction, and the upper bound on the size difference between any two connected components.
The next lines each contain two positive integers , indicating that there is a bidirectional road between city and city . It is guaranteed that .
Output Format
Output one number, the answer modulo .
4 4 1
1 2
2 3
1 3
3 4
2
见附件中的 cities/cities2.in
见附件中的 cities/cities2.ans
见附件中的 cities/cities3.in
见附件中的 cities/cities3.ans
见附件中的 cities/cities4.in
见附件中的 cities/cities4.ans
Hint
Sample 1 Explanation
There are the following two cases:
- Originally there was only the edge . Then there are three connected components: , , . Later, cities decided to additionally build the three edges , , among these three cities, making all cities connected.
- Originally there were no edges at all. Then there are four connected components: , , , . Later, cities decided to additionally build the four edges , , , among these four cities, making all cities connected.
Constraints
For all testdata, it is guaranteed that: , , .
| Test Point | |||
|---|---|---|---|
| 1, 2 | |||
| 3 ~ 5 | |||
| 6, 7 | |||
| 8, 9 | |||
| 10, 11 | |||
| 12, 13 | |||
| 14, 15 | |||
| 16, 17 | |||
| 18 ~ 20 |
Translated by ChatGPT 5