QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100

#11157. 测速摄像头

Statistics

Bytetown 的市长计划在城市中安装若干个雷达测速摄像头。Bytetown 共有 $n$ 个路口,编号从 $1$ 到 $n$,以及 $n-1$ 条双向街道。每条街道连接两个路口。该街道网络保证从任意一个路口出发都可以到达其他任何路口。

测速摄像头将安装在路口(每个路口最多安装一个),市长希望最大化摄像头的数量。然而,为了不让 Byteland 的驾驶员感到过于不满,他决定在 Bytetown 的任意一条不经过重复路口的路径上,最多只能有 $k$ 个摄像头(包括路径端点上的摄像头)。

你的任务是编写一个程序,确定应该在哪些路口安装测速摄像头。

输入格式

输入的第一行包含两个整数 $n$ 和 $k$ ($1 \le n, k \le 1\,000\,000$):Bytetown 的路口数量以及单条路径上允许安装的摄像头的最大数量。接下来的 $n-1$ 行描述了 Bytetown 的街道网络:第 $i$ 行包含两个整数 $a_i$ 和 $b_i$ ($1 \le a_i, b_i \le n$),表示有一条连接编号为 $a_i$ 和 $b_i$ 的路口的双向街道。

输出格式

第一行输出 $m$:表示可以在 Byteland 安装的摄像头的最大数量。第二行输出一个包含 $m$ 个数字的序列,描述安装摄像头的路口编号。如果存在多种方案,输出其中任意一种即可。

样例

输入格式 1

5 2
1 3
2 3
3 4
4 5

输出格式 1

3
1 2 4

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.