QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 512 MB Puntuación total: 100

#10350. 星辰

Estadísticas

小 Y 是一位富有想像力的女孩。

一天夜裡,小 Y 望著滿天的星辰,開始用自己之前學到的天文知識,逐個辨認星座。不過這次,她希望在前人的基礎上添加些自己的創意,從而得到屬於自己的圖案。

天空中共有 $n$ 顆星星。小 Y 透過翻閱古今中外的各種典籍,得到了 $m$ 段資料。其中,第 $i$ 段資料說星星 $a_i$ 和星星 $b_i$ 之間應該有一條連線。對於每段資料,小 Y 還根據它的年代、出處等資訊,給了這條連線一個權值 $c_i$。

小 Y 想從這 $m$ 段資料中選出一些,根據其中的資訊將星星連接起來,作為自己的圖案。

小 Y 希望這樣得到的圖案中沒有重邊,也就是說任意兩顆星星之間至多有一條邊。並且這個圖案應該是連通的。

除此之外,由於今年是 2017 年,小 Y 希望她選出邊的權值和對 $p = 17$ 取模的結果為某個特定的數。於是小 Y 想知道,對於 $0 \le k < p$ 中的每一個 $k$,滿足圖案連通無重邊並且邊權和對 $p$ 取模的結果為 $k$ 的方案數是多少?

由於答案可能很大,你只需要告訴小 Y 答案對 $998244353$ 取模的結果。

輸入格式

從標準輸入讀入資料。

第一行有兩個整數 $n, m$,含義如題述。

接下來 $m$ 行,每行三個整數 $a_i, b_i, c_i$,表示有一條連接 $a_i$ 和 $b_i$ 的,權值為 $c_i$ 的邊。

輸出格式

輸出到標準輸出。

輸出共 $p$ 行,每行一個整數,第 $i$ 行表示邊權和模 $p$ 為 $i - 1$ 的方案數對 $998244353$ 取模的結果。

範例

範例輸入 1

4 8
1 2 0
1 2 1
2 3 0
2 3 1
3 4 0
3 4 1
1 4 0
1 4 2

範例輸出 1

5
12
13
11
6
1
0
0
0
0
0
0
0
0
0
0
0

子任務

每個測試點的資料規模及特點如下表所示。

測試點 $n$ $m$ 其他約定
1 $\le 17$ $\le 20$
2 $\le 25$
3 $\le 30$
4 $\le 10^5$ 權值均為 $0$
5
6 $\le 14$ $\le 50$ 權值均為 $1$
7
8 $\le 15$
9
10
11 $\le 13$ $\le 10^5$
12 $\le 14$
13
14 $\le 15$
15
16 $\le 16$
17
18
19
20 $\le 17$
21
22
23
24
25

對於 100% 的資料,保證 $1 \le n \le 17, 1 \le m \le 10^5, 0 \le c_i < p = 17$。

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.