#P9167. [省选联考 2023] 城市建造

[省选联考 2023] 城市建造

Problem Description

In this country, there are nn cities. At the beginning, there are some bidirectional roads between the cities, which makes these cities form t2t \ge 2 connected components. In particular, for any two components, the absolute difference of their sizes is at most 0k10 \le k \le 1. To make city construction and development easier, among the nn cities, some tt cities built at least one additional bidirectional road among these tt cities, so that all cities become connected.

Now all roads after adding are known. You need to determine which sets of bidirectional roads EE' could possibly be the roads added later. Output the result modulo 998,244,353998,244,353.

That is, given an undirected connected graph G=(V,E)G = (V, E) with nn vertices and mm edges, ask how many subgraphs G=(V,E)G' = (V', E') satisfy EE' \ne \varnothing, and GEG - E' has exactly V|V'| connected components, and the size difference between any two connected components is at most kk. It is guaranteed that 0k10 \le k \le 1. Output the result modulo 998,244,353998,244,353.

Input Format

The first line contains three positive integers n,m,kn, m, k, 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 mm lines each contain two positive integers u,vu, v, indicating that there is a bidirectional road between city uu and city vv. It is guaranteed that uvu \ne v.

Output Format

Output one number, the answer modulo 998,244,353998,244,353.

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 (3,4)(3, 4). Then there are three connected components: {1}\{1\}, {2}\{2\}, {3,4}\{3, 4\}. Later, cities 1,2,31, 2, 3 decided to additionally build the three edges (1,2)(1, 2), (2,3)(2, 3), (1,3)(1, 3) among these three cities, making all cities connected.
  • Originally there were no edges at all. Then there are four connected components: {1}\{1\}, {2}\{2\}, {3}\{3\}, {4}\{4\}. Later, cities 1,2,3,41, 2, 3, 4 decided to additionally build the four edges (1,2)(1, 2), (2,3)(2, 3), (1,3)(1, 3), (3,4)(3, 4) among these four cities, making all cities connected.

Constraints

For all testdata, it is guaranteed that: 3n1053 \le n \le 10^5, n1m2×105n - 1 \le m \le 2 \times 10^5, 0k10 \le k \le 1.

Test Point nn mm kk
1, 2 15\le 15 20\le 20 =0= 0
3 ~ 5 20\le 20 50\le 50 =1= 1
6, 7 200\le 200 300\le 300 =0= 0
8, 9 2,000\le 2,000 =n1= n - 1 =1= 1
10, 11 3,000\le 3,000 =0= 0
12, 13 =1= 1
14, 15 105\le 10^5 =n1= n - 1
16, 17 2×105\le 2 \times 10^5 =0= 0
18 ~ 20 =1= 1

Translated by ChatGPT 5