#P2323. [HNOI2006] 公路修建问题
[HNOI2006] 公路修建问题
Description
OI island is a very beautiful island, and since its development, many people have come to travel here. However, because the island has only recently been developed, its transportation system is still poor. Therefore, the OIER Association was founded to build the transportation system of OI island.
OI island has tourist attractions, labeled from to . Now, the OIER Association needs to build roads to connect these attractions. A road connects two attractions. There are two types of roads, which we call Type 1 roads and Type 2 roads. Cars travel faster on Type 1 roads, but they cost more to build.
The OIER Association plans to build roads to connect all attractions (so that there is a path between any two attractions). To ensure the efficiency of the road system, the OIER Association wants at least () of these roads to be Type 1 roads. The OIER Association also does not want any single road to be too expensive. Therefore, under the above conditions, they want the cost of the most expensive road to be as small as possible. Your task is, given some candidate roads, to choose roads that satisfy the above conditions.
Input Format
- The first line contains three numbers (), (), and (), separated by spaces. Here and are as described above, and means there are pairs of attractions between which a road can be built.
- The following lines each contain four positive integers (, , ), indicating that a road can be built between attractions and . If a Type 1 road is built, the cost is ; if a Type 2 road is built, the cost is .
- In actual judging, there will be only road entries.
Output Format
- The first line contains a single number, which is the cost of the most expensive road among the chosen roads.
- The next lines each contain two positive integers and . Here and indicate that on the -th pair of attractions in the input (indexed from in input order), a Type road is built.
- The lines must be output in increasing order of . If multiple solutions achieve the minimal value of the maximum road cost, output any one of them.
4 2 5
1 2 6 5
1 3 3 1
2 3 9 4
2 4 6 1
6
1 1
2 1
4 1
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号