树干AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)You are given a tree with $N$ vertices numbered $1$ to $N$. The $i$-th edge ($1 \le i \le N - 1$) connects vertices $A_i$ and $B_i$. For a path in this tree, define the score of the path as the distance from the path to the farthest vertex. Here, the distance from a path is defined as the minimum distance to a vertex on the path.
给定一棵有 $N$ 个顶点的树,顶点编号为 $1$ 至 $N$。第 $i$ 条边($1 \le i \le N - 1$)连接顶点 $A_i$ 和 $B_i$。对于树中的一条路径,定义该路径的得分为该路径到最远顶点的距离。这里,顶点到一条路径的距离定义为该顶点到路径上某个顶点的最小距离。AI (CI翻译)
A path with the minimum score is called a good path.
得分最小的路径称为优良路径。AI (CI翻译)
For each $k = 1, 2, \ldots, N$, find the number of good paths with exactly $k$ vertices. Paths are distinguished only if their vertex sets differ.
对于每个 $k = 1, 2, \ldots, N$,求恰好包含 $k$ 个顶点的优良路径数量。仅当两条路径的顶点集合不同时,才认为它们不同。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$2 \le N \le 2 \times 10^5$$1 \le A_i < B_i \le N$($1 \le i \le N - 1$)- The given graph is a tree.
- All input values are integers.
$2 \le N \le 2 \times 10^5$$1 \le A_i < B_i \le N$($1 \le i \le N - 1$)- 给定的图是一棵树。
- 所有输入值均为整数。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入按以下格式给出:AI (CI翻译)
N
A_1 B_1
A_2 B_2
\vdots
A_{N - 1} B_{N - 1}
N
A_1 B_1
A_2 B_2
\vdots
A_{N - 1} B_{N - 1}AI (CI翻译)
Output
输出格式
AI (CI翻译)Output $N$ lines.
输出 $N$ 行。AI (CI翻译)
The $k$-th line should contain the number of good paths with exactly $k$ vertices.
第 $k$ 行应输出恰好包含 $k$ 个顶点的优良路径数量。AI (CI翻译)
样例
5
1 2
2 3
2 4
3 5
0
1
3
2
0
8
1 2
2 3
2 4
3 5
5 6
3 7
7 8
1
3
7
8
5
0
0
0
5
1 2
2 3
3 4
4 5
0
0
0
0
1
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。