#P2330. [SCOI2005] 繁忙的都市

    ID: 1307 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>图论2005四川并查集各省省选生成树

[SCOI2005] 繁忙的都市

Description

City C is a very busy metropolis, and its roads are heavily congested. The mayor decides to renovate some of the roads. The road network in city C is as follows: there are nn intersections in the city. Some pairs of intersections are connected by roads, and there is at most one road between any pair of intersections. These roads are bidirectional and connect all intersections directly or indirectly. Each road has a score cc: the smaller the score, the more congested the road is and the more it needs renovation. However, the budget is limited, so the mayor wants to renovate as few roads as possible. The requirements are:

  1. The renovated roads must connect all intersections directly or indirectly.
  2. Subject to requirement 1, the number of renovated roads should be as small as possible.
  3. Subject to requirements 1 and 2, among the renovated roads, the maximum score should be as small as possible.

Task: As the city planning bureau, you should make the best decision and choose which roads should be renovated.

Input Format

The first line contains two integers n,mn, m, meaning there are nn intersections and mm roads.

Each of the next mm lines describes a road with three integers u,v,cu, v, c, meaning there is a road between intersections uu and vv with score cc.

Output Format

Output two integers s,maxs, \mathit{max}, meaning you selected ss roads, and the maximum score among the selected roads is max\mathit{max}.

4 5
1 2 3
1 4 5
2 4 7
2 3 6
3 4 8

3 6

Hint

Constraints

For all testdata, 1n3001 \le n \le 300, 1c1041 \le c \le 10^4, 1m80001 \le m \le 8000.

Translated by ChatGPT 5