Codeforces Round 862 (Div. 2)
D
A Wide, Wide Graph
Codeforces
1800
原题
← CE →
翻译中…

You are given a tree (a connected graph without cycles) with $n$ vertices.

翻译中…

Consider a fixed integer $k$. Then, the graph $G_k$ is an undirected graph with $n$ vertices, where an edge between vertices $u$ and $v$ exists if and only if the distance between vertices $u$ and $v$ in the given tree is at least $k$.

翻译中…

For each $k$ from $1$ to $n$, print the number of connected components in the graph $G_k$.

翻译中…

Input

翻译中…

The first line contains the integer $n$ ($2 \le n \le 10^5$) — the number of vertices in the graph.

翻译中…

Each of the next $n-1$ lines contains two integers $u$ and $v$ ($1 \le u, v \le n$), denoting an edge between vertices $u$ and $v$ in the tree. It is guaranteed that these edges form a valid tree.

翻译中…

Output

翻译中…

Output $n$ integers: the number of connected components in the graph $G_k$ for each $k$ from $1$ to $n$.

翻译中…

Note

翻译中…

In the first example: If $k=1$, the graph has an edge between each pair of vertices, so it has one component. If $k=4$, the graph has only edges $4 \leftrightarrow 6$ and $5 \leftrightarrow 6$, so the graph has $4$ components.

翻译中…

In the second example: when $k=1$ or $k=2$ the graph has one component. When $k=3$ the graph $G_k$ splits into $3$ components: one component has vertices $1$, $4$ and $5$, and two more components contain one vertex each. When $k=4$ or $k=5$ each vertex is a separate component.

翻译中…

样例

Input #1
6
1 2
1 3
2 4
2 5
3 6
Output #1
1 1 2 4 6 6
InputCopy OutputCopy
Input #2
5
1 2
2 3
3 4
3 5
Output #2
1 1 3 5 5
InputCopy OutputCopy
题目信息
题号
1805D
时间限制
1 s
内存限制
256 MB
标签
DFS 及类似
动态规划
图论
贪心
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。