CF1266F Almost Same Distance
题目描述
给出一颗$n$个点的树($2\leq n\leq 5\times 10^5$),对于$k\in[1,n]$,分别找出一个最大的点集,使得点集内任意两点间距离为$k$或$k+1$。
输入格式
第一行输入一个整数$n$,表示树的结点数。
接下来$n-1$行,每行两个整数$u_i,v_i$,表示$u_i,v_i$间有一条边($1\leq u_i,v_i\leq n\ $)。
输出格式
输出一行$n$个整数,第$i$个整数,表示当$k=i\ $时,对应的最大点集结点数。
说明/提示
Consider the first example.
- The only maximum almost- $ 1 $ -uniform set is $ \{1, 2, 3, 4\} $ .
- One of the maximum almost- $ 2 $ -uniform sets is or $ \{2, 3, 5\} $ , another one is $ \{2, 3, 4\} $ .
- A maximum almost- $ 3 $ -uniform set is any pair of vertices on distance $ 3 $ .
- Any single vertex is an almost- $ k $ -uniform set for $ k \geq 1 $ .
In the second sample there is an almost- $ 2 $ -uniform set of size $ 4 $ , and that is $ \{2, 3, 5, 6\} $ .