QOJ.ac

QOJ

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

#891. 最小生成树

统计

MianKing 有一个包含 $n$ 个节点和 $m$ 条边的图,其中第 $i$ 条边 $(x_i, y_i)$ 的边权为 $w_i$。 图的最小生成树是指边权之和最小的生成树。 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.