CF1266F.Almost Same Distance
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Let G be a simple graph. Let W be a non-empty subset of vertices. Then W is almost- k -uniform if for each pair of distinct vertices u,v∈W the distance between u and v is either k or k+1 .
You are given a tree on n vertices. For each i between 1 and n , find the maximum size of an almost- i -uniform set.
输入格式
The first line contains a single integer n ( 2≤n≤5⋅105 ) – the number of vertices of the tree.
Then n−1 lines follows, the i -th of which consisting of two space separated integers ui , vi ( 1≤ui,vi≤n ) meaning that there is an edge between vertices ui and vi .
It is guaranteed that the given graph is tree.
输出格式
Output a single line containing n space separated integers ai , where ai is the maximum size of an almost- i -uniform set.
输入输出样例
输入#1
5 1 2 1 3 1 4 4 5
输出#1
4 3 2 1 1
输入#2
6 1 2 1 3 1 4 4 5 4 6
输出#2
4 4 2 1 1 1
说明/提示
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≥1 .
In the second sample there is an almost- 2 -uniform set of size 4 , and that is {2,3,5,6} .