CF980E.The Number Games

提高+/省选-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

The nation of Panel holds an annual show called The Number Games, where each district in the nation will be represented by one contestant.

The nation has nn districts numbered from 11 to nn, each district has exactly one path connecting it to every other district. The number of fans of a contestant from district ii is equal to 2i2^i.

This year, the president decided to reduce the costs. He wants to remove kk contestants from the games. However, the districts of the removed contestants will be furious and will not allow anyone to cross through their districts.

The president wants to ensure that all remaining contestants are from districts that can be reached from one another. He also wishes to maximize the total number of fans of the participating contestants.

Which contestants should the president remove?

国家“Panel”每年举办一场名为“数字大赛”的盛会,该国每个地区均派出一名选手参赛。

该国共有 nn 个地区,编号从 11 到 nn,任意两个地区之间都恰好存在一条路径相连(即整个地区网络构成一棵树)。来自第 ii 个地区的选手所拥有的粉丝数为 2i2^i。

今年,总统决定缩减开支,计划从大赛中移除 kk 名选手。然而,被移除选手所在地区将极为愤怒,拒绝任何人穿越其地区。

总统希望确保所有留下的选手所属的地区彼此之间仍可互相到达(即剩余地区在移除对应节点后仍构成一个连通子图)。同时,他还希望最大化所有参赛选手的粉丝总数。

总统应当移除哪 kk 名选手?

输入格式

The first line of input contains two integers nn and kk (1≤k<n≤1061 \leq k \lt n \leq 10^6) — the number of districts in Panel, and the number of contestants the president wishes to remove, respectively.

The next n−1n-1 lines each contains two integers aa and bb (1≤a,b≤n1 \leq a, b \leq n, a≠ba \ne b), that describe a road that connects two different districts aa and bb in the nation. It is guaranteed that there is exactly one path between every two districts.

输入的第一行包含两个整数 nn 和 kk(1≤k<n≤1061 \leq k \lt n \leq 10^6),分别表示 Panel 国的行政区数量,以及总统希望移除的参赛者数量。

接下来的 n−1n-1 行每行包含两个整数 aa 和 bb(1≤a,b≤n1 \leq a, b \leq n,且 a≠ba \ne b),描述一条连接两个不同行政区 aa 和 bb 的道路。保证任意两个行政区之间恰好存在一条路径。

输出格式

Print kk space-separated integers: the numbers of the districts of which the contestants should be removed, in increasing order of district number.

输出 kk 个用空格分隔的整数:应移除参赛者的行政区编号,按行政区编号升序排列。

输入输出样例

  • 输入#1

    6 3
    2 1
    2 6
    4 2
    5 6
    2 3

    输出#1

    1 3 4
  • 输入#2

    8 4
    2 6
    2 7
    7 8
    1 2
    3 1
    2 4
    7 5

    输出#2

    1 3 4 5

说明/提示

In the first sample, the maximum possible total number of fans is 22+25+26=1002^2 + 2^5 + 2^6 = 100. We can achieve it by removing the contestants of the districts 1, 3, and 4.

在第一个样例中,粉丝总数的最大可能值为 22+25+26=1002^2 + 2^5 + 2^6 = 100。我们可以通过移除第 1、3 和 4 号区域的参赛者来实现该值。

输入解题思路,AI测评打分。不知道怎么写?

首页