#P6790. [SNOI2020] 生成树

    ID: 7426 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>树形数据结构2020各省省选组合数学

[SNOI2020] 生成树

Problem Description

Given an undirected connected graph GG. It is known that after deleting one edge, GG becomes a cactus (cactus: an undirected connected graph in which no two simple cycles share a common edge). Find the number of spanning trees of GG. Output the result modulo 998244353998244353.

Input Format

The first line contains two integers n,mn, m, denoting the number of vertices and edges of graph GG.

The next mm lines each contain two positive integers u,vu, v separated by a space (1u,vn)(1 \le u, v \le n), denoting an edge (u,v)G(u, v) \in G.

Output Format

Output one line with one integer, denoting the number of spanning trees of GG modulo 998244353998244353.

4 5
1 2
1 3
2 3
2 4
3 4
8

Hint

Constraints: For all testdata, 1nm2×1051 \le n \le m \le 2 \times 10^5.

  • For 10%10\% of the testdata, 1n=m20001 \le n = m \le 2000.
  • For another 40%40\% of the testdata, 1n,m1051 \le n, m \le 10^5 and GG itself is a cactus.
  • For the remaining 50%50\% of the testdata, there are no special constraints.

Translated by ChatGPT 5