CF958B2.Maximum Control (medium)

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The Resistance is trying to take control over as many planets of a particular solar system as possible. Princess Heidi is in charge of the fleet, and she must send ships to some planets in order to maximize the number of controlled planets.

The Galaxy contains NN planets, connected by bidirectional hyperspace tunnels in such a way that there is a unique path between every pair of the planets.

A planet is controlled by the Resistance if there is a Resistance ship in its orbit, or if the planet lies on the shortest path between some two planets that have Resistance ships in their orbits.

Heidi has not yet made up her mind as to how many ships to use. Therefore, she is asking you to compute, for every K=1,2,3,...,NK=1,2,3,...,N , the maximum number of planets that can be controlled with a fleet consisting of KK ships.

输入格式

The first line of the input contains an integer NN ( 1<=N<=1051<=N<=10^{5} ) – the number of planets in the galaxy.

The next N1N-1 lines describe the hyperspace tunnels between the planets. Each of the N1N-1 lines contains two space-separated integers uu and vv ( 1<=u,v<=N1<=u,v<=N ) indicating that there is a bidirectional hyperspace tunnel between the planets uu and vv . It is guaranteed that every two planets are connected by a path of tunnels, and that each tunnel connects a different pair of planets.

输出格式

On a single line, print NN space-separated integers. The KK -th number should correspond to the maximum number of planets that can be controlled by the Resistance using a fleet of KK ships.

输入输出样例

  • 输入#1

    3
    1 2
    2 3
    

    输出#1

    1 3 3 
  • 输入#2

    4
    1 2
    3 2
    4 2
    

    输出#2

    1 3 4 4 

说明/提示

Consider the first example. If K=1K=1 , then Heidi can only send one ship to some planet and control it. However, for K>=2K>=2 , sending ships to planets 1 and 3 will allow the Resistance to control all planets.

首页