当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3538:Domestic Networks

Special Judge 特殊评判
题目描述

Alex is a system administrator of Domestic Networks Inc. His network connects apartments and spans over multiple buildings.

The network expands and Alex has to design a new network segment. He has a map that shows apartments to connect and possible links. Each link connects two apartments and for each possible link its length is known. The goal is to make all apartments connected (possibly through other apartments).

Domestic Networks Inc. buys cable in the nearest cable shop. Unfortunately, shop sells only category 5 and 6 cables at price of p5 and p6 rubles per meter respectively. Moreover, there are only q5 meters of category 5 cable and q6 meters of category 6 cable available in the shop.

Help Alex to solve a hard problem: make a new network construction plan with possible minimal cost. A plan consists of list of links to be made and cable category for each link (each link should be a single piece of cable of either 5 or 6 category). The cost of the plan is the sum of cost of all cables. The total length of cables of each category used in the plan should not exceed the quantity of the cable available in the shop.

输入解释

The first line of the input file contains two numbers: n — the number of apartments to be connected and m — the number of possible links (1 ≤ n ≤ 1000, 1 ≤ m10 000).

Following m lines contain possible link descriptions. Each description consists of three integer numbers: ai and bi — apartments that can be connected by the link and li — link length in meters (0 ≤ li ≤ 100). Apartments are numbered from 1 to n.

The last line of the input file contains four integer numbers: p5, q5, p6 and q6 — price and quantity of category 5 and 6 cables respectively (1 ≤ pi, qi10 000).

输出解释

If all apartments can be connected with the available cable, output n lines — an optimal network construction plan. The first line of the plan must contain plan’s cost. Other lines of the plan must consist of two integer numbers each: ai — number of the link to make and ci — the category of the cable to make it of. Links are numbered from 1 to m in the order they are specified in the input file. If there are more than one optimal plans, output any of them.

If there is no plan meeting all requirements, output a single word “Impossible”.

输入样例
6 7
1 2 7
2 6 5
1 4 8
2 3 5
3 4 5
5 6 6
3 5 3
2 11 3 100
输出样例
65
1 5
2 6
4 6
5 6
7 5

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3538

最后修改于 2020-10-29T07:03:59+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 65536