QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 256 MB Puntuación total: 100

#891. Cây khung nhỏ nhất

Estadísticas

MianKing có một đồ thị với $n$ đỉnh và $m$ cạnh, trong đó cạnh thứ $i$ $(x_i, y_i)$ có trọng số là $w_i$. Cây khung nhỏ nhất (Minimum Spanning Tree) của đồ thị là một cây khung có tổng trọng số các cạnh là nhỏ nhất. MianKing đã quên các trọng số $w_{1 \dots m}$, nhưng anh ấy vẫn nhớ rằng $w_{1 \dots m}$ là một hoán vị của $\{1 \dots m\}$ và tập hợp các cạnh của cây khung nhỏ nhất của đồ thị này bao gồm $n - 1$ cạnh đầu tiên. Bây giờ bạn cần giúp MianKing tính xem có bao nhiêu hoán vị $w_{1 \dots m}$ thỏa mãn các điều kiện trên. Kết quả có thể rất lớn, vì vậy bạn chỉ cần in ra kết quả theo modulo $998\,244\,353$.

Dữ liệu vào

Dòng đầu tiên chứa hai số nguyên $n$ và $m$ ($2 \le n \le 20$, $n - 1 \le m \le 100$). Tiếp theo là $m$ dòng, dòng thứ $i$ chứa hai số nguyên $x_i$ và $y_i$ ($1 \le x_i, y_i \le n$). Đảm bảo rằng các cạnh $(x_1, y_1), \dots, (x_{n-1}, y_{n-1})$ tạo thành một cây với $n$ đỉnh. Lưu ý rằng đồ thị có thể có nhiều cạnh nối giữa hai đỉnh và khuyên (self-loop).

Dữ liệu ra

In ra kết quả theo modulo $998\,244\,353$.

Ví dụ

Dữ liệu vào 1

3 3
1 2
2 3
3 1

Dữ liệu ra 1

2

Dữ liệu vào 2

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

Dữ liệu ra 2

25

Dữ liệu vào 3

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

Dữ liệu ra 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.