poj3107 Godfather(鬼题畜译)

来源:互联网 发布:刻绘大师端口怎么设置 编辑:程序博客网 时间:2024/06/06 22:50

译文:
问题描述:

去年芝加哥发生了很多起谋杀案以及黑帮之间的火拼,警察局长真的是受够了这些罪犯,所以ta做了一个大胆的决定:擒贼先擒王——抓住黑手党老大(基里连科?)
这里写图片描述
不幸的是,芝加哥黑手党的内部结构相当复杂。现在警察锁定了n个人与黑手党有关。警察追踪他们的活动已经有一段时间了,并且知道他们中的一些人互相有往来。根据收集的数据,警察局长发现黑手党的等级制度可以用一棵树来表示。黑手党的首领,教父基里连科,是树的根,如果某个人用树中的一个节点来表示,ta的直接下属就由该节点的子节点来表示。为了不过度暴露,匪徒只与他们的直接下属和他们的直接上司沟通。
不幸的是,尽管警察知道匪徒的通讯往来,但他们不知道谁是通讯往来的上司。也就是说,他们只有一棵没有方向性的通讯树,并不知道教父是谁。
基于一般的认知,警察局长提出了一个假设,:黑手党教父希望拥有最大的权利。也就是说:逮捕ta之后,通信树中的最大剩余的连通块尽可能小。请帮助警察找到所有可能是的教父嫌疑犯,以便警察逮捕这些嫌疑犯。
这里写图片描述
输入
第一行包含一个n ,表示疑似黑手党的嫌疑犯的数量(2≤n≤50 000)。ta们的编号从1到n。
以下n-1行包含两个整数a,b,表示着歹徒a与歹徒b有沟通。保证是一棵树。

输出
输出所有被怀疑是教父的人的编号。数字必须以递增的顺序打印出来,用空格隔开。

样例输入
6个
1 2
2 3
2 5
3 4
3 6

样例输出
2 3
这里写图片描述

原文:
Description

Last years Chicago was full of gangster fights and strange murders. The chief of the police got really tired of all these crimes, and decided to arrest the mafia leaders.

Unfortunately, the structure of Chicago mafia is rather complicated. There are n persons known to be related to mafia. The police have traced their activity for some time, and know that some of them are communicating with each other. Based on the data collected, the chief of the police suggests that the mafia hierarchy can be represented as a tree. The head of the mafia, Godfather, is the root of the tree, and if some person is represented by a node in the tree, its direct subordinates are represented by the children of that node. For the purpose of conspiracy the gangsters only communicate with their direct subordinates and their direct master.

Unfortunately, though the police know gangsters’ communications, they do not know who is a master in any pair of communicating persons. Thus they only have an undirected tree of communications, and do not know who Godfather is.

Based on the idea that Godfather wants to have the most possible control over mafia, the chief of the police has made a suggestion that Godfather is such a person that after deleting it from the communications tree the size of the largest remaining connected component is as small as possible. Help the police to find all potential Godfathers and they will arrest them.

Input

The first line of the input file contains n — the number of persons suspected to belong to mafia (2 ≤ n ≤ 50 000). Let them be numbered from 1 to n.

The following n − 1 lines contain two integer numbers each. The pair ai, bi means that the gangster ai has communicated with the gangster bi. It is guaranteed that the gangsters’ communications form a tree.

Output

Print the numbers of all persons that are suspected to be Godfather. The numbers must be printed in the increasing order, separated by spaces.

Sample Input
6
1 2
2 3
2 5
3 4
3 6

Sample Output
2 3