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

建议使用的浏览器:

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

3380:Bridges

Special Judge 特殊评判
题目描述

Once upon a time there was a country in a delta of a far-away river. The country had n islands and there was a town on each island. The towns were connected by roads. There was exactly one route from each town to each other one (possibly passing through some intermediate towns). Unfortunately, each road had to cross the river with a ford, since bridges were not known, so the travel was quite uncomfortable and could only be made by a horse.

When Bridge Building technology was discovered the king decided to build bridges instead of some fords to make roads easier to travel. Bridges would allow fords to be crossed even by carriages. The king liked the idea with bridges and ordered to build as many bridges as possible. Unfortunately, the country was quite poor, so only k bridges could be built.

The king asked you — his major advisor — to develop a bridge building plan. You have to choose k fords in such a way that the sum of travel times between all pairs of towns becomes as small as possible. You must assume that the ordinary roads would be traveled by horses, and roads enhanced with bridges would be traveled by carriages.

输入解释

The first line of the input file contains four integer numbers: n, k, sh and sc — the number of towns in the country, the number of bridges to build (1 ≤ k < n10 000), the speed of the horse and the speed of the carriage in meters per second (1 ≤ sh, sc100 000).

Each of the following n − 1 lines contains three integer numbers: bi, ei — the towns connected by the road, and li — the road length in meters (1 ≤ li ≤ 106). Towns are numbered from 1 to n, roads are numbered from 1 to n − 1.

输出解释

Output k numbers — the numbers of roads where the bridges should be built. If there are several possible optimal bridge building plans, output any of them.

输入样例
6 2 1 2
1 2 5
3 2 6
1 4 4
4 6 4
4 5 5
输出样例
1 3
提示

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

源链接: POJ-3380

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

共提交 0

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