#abc269h. Ex - Antichain
Ex - Antichain
Score : points
问题描述
我们有一个包含 个顶点的有根树 ,顶点编号为 到 。顶点 是树的根节点,且顶点 的父节点是顶点 。
对于树 的顶点集合 中的一个非空子集 ,如果满足以下条件,则称其为一个好顶点集合:
- 对于 中每一对不同的顶点 ,都满足: 不是 的祖先。
对于每个 ,求恰好包含 个顶点的好顶点集合的数量,结果对 取模。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have a rooted tree with vertices numbered to . Vertex is the root, and the parent of vertex is vertex .
A non-empty subset of the vertex set of is said to be a good vertex set when it satisfies the following condition.
- For every pair of different vertices in , the following holds: is not an ancestor of .
For each , find the number, modulo , of good vertex sets with exactly vertices.
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the answer for .
Sample Input 1
4
1 2 1
Sample Output 1
4
2
0
0
For each , the good vertex sets of size are listed below.
- : $\lbrace 1 \rbrace, \lbrace 2 \rbrace, \lbrace 3 \rbrace, \lbrace 4 \rbrace$.
- : .
- : 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