#abc269h. Ex - Antichain

Ex - Antichain

Score : 600600 points

问题描述

我们有一个包含 NN 个顶点的有根树 TT,顶点编号为 11NN。顶点 11 是树的根节点,且顶点 ii (2iN)(2 \leq i \leq N) 的父节点是顶点 PiP_i

对于树 TT 的顶点集合 V={1,2,,N}V = \lbrace 1, 2,\dots, N\rbrace 中的一个非空子集 SS,如果满足以下条件,则称其为一个好顶点集合

  • 对于 SS 中每一对不同的顶点 (u,v)(u, v),都满足:uu 不是 vv 的祖先。

对于每个 K=1,2,,NK = 1, 2, \dots, N,求恰好包含 KK 个顶点的好顶点集合的数量,结果对 998244353998244353 取模。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

We have a rooted tree TT with NN vertices numbered 11 to NN. Vertex 11 is the root, and the parent of vertex ii (2iN)(2 \leq i \leq N) is vertex PiP_i.

A non-empty subset SS of the vertex set V={1,2,,N}V = \lbrace 1, 2,\dots, N\rbrace of TT is said to be a good vertex set when it satisfies the following condition.

  • For every pair of different vertices (u,v)(u, v) in SS, the following holds: uu is not an ancestor of vv.

For each K=1,2,,NK = 1, 2, \dots, N, find the number, modulo 998244353998244353, of good vertex sets with exactly KK vertices.

Constraints

  • 2N2×1052 \leq N \leq 2 \times 10^5
  • 1Pi<i1 \leq P_i \lt i
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN

P2P_2 P3P_3 \dots PNP_N

Output

Print NN lines. The ii-th line should contain the answer for K=iK = i.

Sample Input 1

4
1 2 1

Sample Output 1

4
2
0
0

For each 1KN1 \leq K \leq N, the good vertex sets of size KK are listed below.

  • K=1K=1: $\lbrace 1 \rbrace, \lbrace 2 \rbrace, \lbrace 3 \rbrace, \lbrace 4 \rbrace$.
  • K=2K=2: {2,4},{3,4}\lbrace 2, 4 \rbrace, \lbrace 3, 4 \rbrace.
  • K=3,4K=3,4: There is none.

Sample Input 2

6
1 1 2 2 5

Sample Output 2

6
6
2
0
0
0

Sample Input 3

6
1 1 1 1 1

Sample Output 3

6
10
10
5
1
0

Sample Input 4

10
1 2 1 2 1 1 2 6 9

Sample Output 4

10
30
47
38
16
3
0
0
0
0

update @ 2024/3/10 11:22:31