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

建议使用的浏览器:

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

3554:Almost the shortest route

题目描述

N cities (2 ≤ N10 000) are connected by a network of M one-way roads (1 ≤ M < 100 000 000). It is known that these roads do not cross outside the cities. The numeration of the cities and the roads starts from 1.There is at most one road from any city to another one. The length of each road does not exceed 10 000.

The company for which you work sends you on a business trip from city 1 to city N on your personal car. The trip expenses will be compensated to you only if the distance you drive will differ from the shortest possible by no more than K (0 ≤ K10 000).

The task is to determine on which roads you can drive to have the right to the compensation. That means the list of all roads that appear on at least one route from city 1 to city N where the length of the route does not exceed the length of the shortest route by more than K.

输入解释

The input consists of M+1 lines. The first line contains the numbers N, M, and K. Each next line describes one road and contains the initial city number, the final city number and the length of the road. All numbers are integers and separated from each other by one or more spaces.

输出解释

The output consists of several lines. The first line contains the integer L – the number of roads you can use. The following L lines contain the numbers of the roads in ascending order.

输入样例
4 5 1
1 2 1
1 3 4
2 3 1
2 4 3
3 4 1
输出样例
4
1
3
4
5

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

源链接: POJ-3554

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

共提交 0

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