using System; using System.Collections.Generic; using System.Text; namespace Csharp { class Program { static int N; static int[,] Costs = new int[50, 50]; static int[] Scores = new int[50]; static void Main(string[] args) { N = Convert.ToInt32(Console.ReadLine()); while (true) { int a, b; var inputs = Console.ReadLine().Split(); a = Convert.ToInt32(inputs[0]); b = Convert.ToInt32(inputs[1]); if (a == -1 && b == -1) break; Costs[a, b] = 1; Costs[b, a] = 1; } for (int via = 1; via <= N; ++via) { for (int s = 1; s <= N; ++s) { for (int e = 1; e <= N; ++e) { if (Costs[s, via] == 0 || Costs[via, e] == 0 || s == e) continue; if (Costs[s, e] == 0 || Costs[s, e] > Costs[s, via] + Costs[via, e]) Costs[s, e] = Costs[s, via] + Costs[via, e]; } } } int minScore = 987654321; for (int s = 1; s <= N; ++s) { int m = 0; for (int e = 1; e <= N; ++e) { m = Math.Max(m, Costs[s, e]); } Scores[s] = m; minScore = Math.Min(minScore, m); } int presidentNumber = 0; for (int i = 1; i <= N; ++i) { if (Scores[i] == minScore) ++presidentNumber; } Console.WriteLine($"{minScore} {presidentNumber}"); for (int i = 1; i <= N; ++i) { if (Scores[i] == minScore) Console.Write($"{i} "); } } } } |