QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#4811. Be Careful

統計

给定一棵有 $n$ 个顶点的有根树,根节点为 1。如果一个顶点不是根节点且度数为 1,则称其为叶子节点。

problem_4811_1.png

该图对应样例测试,其中叶子节点被标记为红色。

令 $\text{mex}(S)$ 为不在 $S$ 中的最小非负整数。例如,$\text{mex}\{0, 1, 3, 4\} = 2$,$\text{mex}\{2, 3\} = 0$,$\text{mex} \emptyset = 0$。

令 $m$ 为给定树中叶子节点的数量。你将执行以下过程:

  1. 对于每个叶子节点 $u$,在顶点 $u$ 上写入 $\{0, 1, 2, \dots, n\}$ 中的任意整数。
  2. 对于每个非叶子节点 $u$,写入 $u$ 的整数将是所有子节点上所写整数的 $\text{mex}$ 值。

例如,对于上图中描述的第一棵树,如果我们给顶点 4 写入整数 0,给顶点 5 写入整数 3,那么:

  • 写入顶点 2 的整数将是 $\text{mex}\{0\} = 1$。
  • 写入顶点 3 的整数将是 $\text{mex}\{3\} = 0$。
  • 写入顶点 1 的整数将是 $\text{mex}\{1, 0\} = 2$。

总共有 $(n + 1)^m$ 种填充树的方式。对于所有的 $k \in \{0, 1, 2, \dots, n\}$,你想要知道有多少种填充树的方式使得写入顶点 1 的数字恰好为 $k$。由于数字可能非常大,你只需要输出它们对 $998\,244\,353$ 取模的结果。

输入格式

第一行包含一个整数 $n$ ($2 \le n \le 200$)。

接下来的 $n - 1$ 行,每行包含两个整数 $x$ 和 $y$ ($1 \le x, y \le n, x \neq y$),表示顶点 $x$ 和 $y$ 之间有一条边。保证给定的图是一棵树。

输出格式

输出 $n + 1$ 行。第 $i$ 行输出一个整数,表示 $k = i - 1$ 时的答案,对 $998\,244\,353$ 取模。

样例

输入 1

5
1 2
1 3
2 4
2 5

输出 1

55
127
34
0
0
0

输入 2

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

输出 2

69632
265534
133905
47790
12636
1944
0
0
0

输入 3

3
1 2
2 3

输出 3

1
3
0
0

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.