P2951 [USACO09OPEN] Hide and Seek S

题目描述

Bessie is playing hide and seek (a game in which a number of players hide and a single player (the seeker) attempts to find them after which various penalties and rewards are assessed; much fun usually ensues). She is trying to figure out in which of N (2

输入格式

\* Line 1: Two space-separated integers: N and M \* Lines 2..M+1: Line i+1 contains the endpoints for path i: A\_i and B\_i 第一行:两个整数N,M; 第2-M+1行:每行两个整数,表示端点A\_i 和 B\_i 间有一条无向边。

输出格式

\* Line 1: On a single line, print three space-separated integers: the index of the barn farthest from barn 1 (if there are multiple such barns, print the smallest such index), the smallest number of paths needed to reach this barn from barn 1, and the number of barns with this number of paths. 仅一行,三个整数,两两中间空格隔开。表示:距离第一个谷仓最远的谷仓编号(如有多个则输出编号最小的。),以及最远的距离,和有几个谷仓距离第一个谷仓那么远。

说明/提示

The farm layout is as follows: ![](https://cdn.luogu.com.cn/upload/pic/2815.png) Barns 4, 5, and 6 are all a distance of 2 from barn 1. We choose barn 4 because it has the smallest index. 这里谷仓4,5,6距离1号谷仓都是2,但是4编号最小所以输出4.因此最远距离是2且有3个谷仓,依次输出:2和3。  感谢 wjcwinmt 的贡献翻译