310253: CF1805D. A Wide, Wide Graph

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. A Wide, Wide Graphtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

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$.

ExamplesInput
6
1 2
1 3
2 4
2 5
3 6
Output
1 1 2 4 6 6 
Input
5
1 2
2 3
3 4
3 5
Output
1 1 3 5 5 
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

题意翻译

给定一棵 $n$($2\leq n\leq 10^5$)个节点的无根树,对于每个 $k$($1\leq k \leq n$),定义一个无向图 $G_k$,其中由边连接的两个节点 $u$ 和 $v$ 的距离至少为 $k$。请你计算 $G_k$ 的连通块个数。 ## 输入格式 第一行包含整数 $n$。 接下来 $n-1$ 行,每行包含两个整数 $u$ 和 $v$,表示树上的一条无向边。 ## 输出格式 输出共 $n$ 行,每行一个整数,表示 $G_k$ 的连通块个数。 ## 数据范围 $2\leq n\leq 10^5$ ## 提示 第一个样例中,当$k=1$时,所有的点都连通;当$k=4$时,只有$(4,6)$和$(5,6)$两条边连通,所以连通块个数为4。 第二个样例中,当$k=3$时,节点1、4、5构成一个连通块,其余两个节点分别为一个连通块。

加入题单

算法标签: