HHKB プログラミングコンテスト 2022(AtCoder Beginner Contest 235)
Ex
Painting Weighted Graph
AtCoder
⌀ 2967
原题
←G →
翻译中…

Problem Statement

翻译中…

Given is an undirected graph with $N$ vertices and $M$ edges. The $i$-th edge connects Vertices $A_i$ and $B_i$ and has a weight of $C_i$.

翻译中…

Initially, all vertices are painted black. You can do the following operation at most $K$ times.

翻译中…
  • Operation: choose any vertex $v$ and any integer $x$. Paint red all vertices reachable from the vertex $v$ by traversing edges whose weights are at most $x$, including $v$ itself.
翻译中…

How many sets can be the set of vertices painted red after the operations? Find the count modulo $998244353$.

翻译中…

Constraints

翻译中…
  • $2 \leq N \leq 10^5$
  • $0 \leq M \leq 10^5$
  • $1 \leq K \leq 500$
  • $1 \leq A_i,B_i \leq N$
  • $1 \leq C_i \leq 10^9$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N M K
A_1 B_1 C_1
\vdots
A_M B_M C_M

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
3 2 1
1 2 1
2 3 2
Output #1
6
For example, an operation with $(v,x)=(2,1)$ paints Vertices $1,2$ red, and an operation with $(v,x)=(1,0)$ paints Vertex $1$. After at most one operation, the set of vertices painted red can be one of the following six: $\{\},\{1\},\{2\},\{3\},\{1,2\},\{1,2,3\}$.
Input #2
5 0 2
Output #2
16
The given graph may not be connected.
Input #3
6 8 2
1 2 1
2 3 2
3 4 3
4 5 1
5 6 2
6 1 3
1 2 10
1 1 100
Output #3
40
The given graph may have multi-edges and self-loops.
题目信息
题号
abc235_h
时间限制
3 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。