#t536. 繁忙的都市
繁忙的都市
Road Reconstruction
Special for beginners, ^_^
Problem Description
City C is a very busy metropolis, and its roads are terribly congested, so the mayor decided to renovate some of the roads. City C's roads are laid out as follows: there are intersections; some pairs of intersections are connected by roads, and at most one road connects any pair of intersections. These roads are bidirectional and connect all intersections directly or indirectly. Each road has a score: the smaller the score, the busier the road and the more it needs renovation. But the city's budget is limited and the mayor wants to renovate as few roads as possible, so he sets the following requirements:
-
The renovated roads must connect all intersections directly or indirectly.
-
Among the roads satisfying requirement 1, the number of renovated roads should be as small as possible.
-
Among the roads satisfying requirements 1 and 2, the maximum score among the renovated roads should be as small as possible.
As a member of the city planning bureau, you should make the best decision about which roads to build.
Input Format
The first line has two integers : the city has intersections and roads. The next lines describe each road: means there is a road of score between intersections and . (, ).
Output Format
Two integers : how many roads you chose, and the score of the highest-scoring road among them.
Sample Input 1
4 5
1 2 3
1 4 5
2 4 7
2 3 6
3 4 8
Sample Output 1
3 6
Constraints
1s, 1024KiB for each test case.