QOJ.ac

QOJ

Limite de temps : 3 s Limite de mémoire : 512 MB Points totaux : 100

#10350. 星辰

Statistiques

小Yは想像力豊かな女の子です。

ある夜、小Yは満天の星空を見上げ、これまでに学んだ天文学の知識を使って、星座を一つずつ特定し始めました。しかし今回は、先人たちの知識に自分なりの創意工夫を加え、自分だけの星座模様を作りたいと考えました。

空には合計 $n$ 個の星があります。小Yは古今東西の様々な文献を調べ、合計 $m$ 個の情報を得ました。そのうち $i$ 番目の情報には、星 $a_i$ と星 $b_i$ の間に線を引くべきであると記されています。また、それぞれの情報に対して、年代や出典などの情報に基づき、その線に重み $c_i$ を与えました。

小Yは、これら $m$ 個の情報からいくつかを選び、その情報に基づいて星同士を繋ぎ、自分だけの模様を作ろうとしています。

小Yが望む模様には多重辺が含まれてはいけません。つまり、任意の2つの星の間には最大で1本の線しか引くことができません。また、この模様は連結である必要があります。

さらに、今年は2017年であるため、小Yは選んだ辺の重みの総和を $p = 17$ で割った余りが特定の数になることを望んでいます。そこで小Yは、$0 \le k < p$ のそれぞれについて、模様が連結であり、多重辺がなく、かつ辺の重みの総和を $p$ で割った余りが $k$ となるような組み合わせの数がいくつあるかを知りたいと考えています。

答えは非常に大きくなる可能性があるため、答えを $998244353$ で割った余りを求めてください。

入力形式

標準入力から以下の形式で入力が与えられます。

$n$ $m$ $a_1$ $b_1$ $c_1$ $a_2$ $b_2$ $c_2$ $\vdots$ $a_m$ $b_m$ $c_m$

出力形式

合計 $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 17$ $\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

すべてのデータにおいて、$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.