QOJ.ac

QOJ

Time Limit: 6 s Memory Limit: 1024 MB Total points: 100

#7772. Mind Power

Statistics

I used to be a jelly-hyper like you, then I took an arrow in the knee.

I think I'd better use jelly-jumps to prevent losing speed too quickly.

If I really intended to leave here to do something else instead of writing miscellaneous things here, the things just mentioned might be very useful.

Given a tree with $n$ weighted nodes and a feasible distance value $k$, a set $S$ is called "legal" if and only if the distance between any two distinct elements in $S$ on the tree is at least $k$.

For each $m = 1, 2, 3, \dots, n$, find the number of ways to partition the set of vertices of this tree into $m$ unordered non-empty sets, such that each vertex is contained in exactly one of the $m$ sets, and each set is "legal". Output the answers modulo $998244353$.

Input

The first line contains two positive integers $n$ and $k$, representing the number of vertices in the tree and the feasible distance value.

The next $n-1$ lines each contain three integers $x, y, z$, representing the two endpoints of an edge in the tree and the weight of that edge.

Output

A single line containing $n$ integers, representing the answers for $m = 1, 2, 3, \dots, n$ respectively.

Examples

Input 1

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

Output 1

0 1 7 6 1

Input 2

10 3
1 2 1
1 3 1
2 4 1
2 5 1
3 6 1
3 7 1
4 8 1
4 9 1
5 10 1

Output 2

0 0 0 16 308 836 674 206 25 1

Constraints

$2 \leq n \leq 100000, 1 \leq k \leq 10^{14}, 1 \leq x, y \leq n, 1 \leq z \leq 10^9$.

  • Subtask 1 (10 pts): $n \leq 10$
  • Subtask 2 (15 pts): $n \leq 2000$, and all edge weights are 1.
  • Subtask 3 (15 pts): $n \leq 2000$
  • Subtask 4 (15 pts): For $1 \leq i \leq n-1$, the $i$-th edge satisfies $x=i, y=i+1$, and all edge weights are 1.
  • Subtask 5 (15 pts): For $1 \leq i \leq n-1$, the $i$-th edge satisfies $x=i, y=i+1$.
  • Subtask 6 (15 pts): All edge weights are 1.
  • Subtask 7 (15 pts): No special restrictions.

The order of subtasks is not related to their difficulty.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download
#1202EditorialOpen和雨停酱一起吃饭真的好幸福 wwwGotoHiotori2026-03-04 15:27:06View

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.