QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 256 MB 總分: 100

#891. 最小生成樹

统计

MianKing 有一個包含 $n$ 個節點與 $m$ 條邊的圖,其中第 $i$ 條邊 $(x_i, y_i)$ 的權重為 $w_i$。 圖的最小生成樹(Minimum Spanning Tree)是指權重總和最小的生成樹。 MianKing 忘記了權重 $w_{1 \dots m}$,但他仍然記得 $w_{1 \dots m}$ 是 $\{1 \dots m\}$ 的一個排列,且該圖的最小生成樹的邊集由前 $n-1$ 條邊組成。 現在你需要幫助 MianKing 計算有多少種 $w_{1 \dots m}$ 滿足上述條件。答案可能非常大,因此你只需要輸出答案對 $998\,244\,353$ 取模後的結果。

輸入格式

第一行包含兩個整數 $n$ 和 $m$ ($2 \le n \le 20, n-1 \le m \le 100$)。 接下來有 $m$ 行,其中第 $i$ 行包含兩個整數 $x_i$ 和 $y_i$ ($1 \le x_i, y_i \le n$)。 保證邊 $(x_1, y_1), \dots, (x_{n-1}, y_{n-1})$ 組成一棵包含 $n$ 個節點的樹。 注意,圖可能包含重邊與自環。

輸出格式

輸出答案對 $998\,244\,353$ 取模後的結果。

範例

輸入 1

3 3
1 2
2 3
3 1

輸出 1

2

輸入 2

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

輸出 2

25

輸入 3

3 6
1 2
2 3
1 1
1 1
1 1
1 1

輸出 3

720

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.