首页 > 试题广场 >

Wired wire

[编程题]Wired wire
  • 热度指数:2 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 256M,其他语言512M
  • 算法知识视频讲解
P company has a huge data center with n servers. There are n - 1 lines between these servers. If two servers are connected by a wire, data can only be sent from one server to another, but not vise versa. Without considering the direction of data transmission, one server can reach any other servers, which means that all servers are connected. The engineer wants to select a central server which needs to send data to all other servers. To achieve this goal, the direction of some wires should be changed. The engineer is very lazy and he wants to select the server which can result in the least operations on wires.

输入描述:
The first line contains an integer n, (2 <= n <= 100000) - the number of servers. Servers are numbered from 1 to n. Next n - 1 lines contain descriptions of the wire, one wire per line. A wire is described by two integers a, b(1 <= a, b <= n) - the number of the servers connected by the wire. The direction of data transmission is from a to b.


输出描述:
The first line prints the minimum number that the engineer should change. In the second line print all possible central servers. If there are multiple servers, print servers in the increasing order.
示例1

输入

4
3 1
4 2
3 4

输出

0
3

这道题你会答吗?花几分钟告诉大家答案吧!