TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

You are asked to build a highway from Taipei to Kaohsiung. Of course the length should be the shortest in economic concern. There may be several ways to build the shortest one. If that's the case, please build the highway, by selecting from the given roads, such that the number of sites adjacent to the highway is maximized.

More specifically, we assume that there are S sites and some R roads connecting two sites. Each site is assigned to a unique integer between 0 and S-1, and each road is of length 1. Please write a program to solve it.

Input Format

There will be an integer N in the first line, indicating the number of test cases. For each test case there will be two integers, S and R, on their own line. In the following R lines each line contains two integers, xi and yi, denoting that there is a road between site xi and site yi. There may be empty lines between two test cases.

※Taipei is always assigned to 0, and Kaohsiung is always assigned to 1.

※There is always a path from Taipei to Kaohsiung.

※Some sites may be unreachable from Taipei.

※1 ≤ N ≤ 100

※2 ≤ S ≤ 400

※1 ≤ R ≤ 2000

Output Format

For each test case, output the length of the highway, a whitespace, and the maximum number of adjacent sites. Output each case in a single line.

Sample Input 1

4
2 1
0 1

3 3
0 1
1 2
0 2

5 5
0 4
0 2
2 4
1 2
1 4

7 9
0 6
0 2
0 4
2 4
3 4
2 3
3 5
4 5
1 5

Sample Output 1

1 0
1 1
2 1
3 3

Hints

  1. There are only two site, Taipei and Kaohsiung.
  2. Shortest highway from Taipei to Kaohsiung is of length and site 2 is adjacent to Taipei.
  3. There are two shortest paths, 0-2-1 and 0-4-1, both of them have one adjacent site.
  4. There is a unique shortest path from Taipei to Kaohsiung, 0-4-5-1. Sites 2, 3, and 6 are adjacent to them.

Problem Source

Migrated from old NTUJ.

2011 google code jam round 2

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 200