22706_Almosttheshortestrou

2022-5-16 18:22| 发布者: Hocassian| 查看: 31| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506877155200-Problem List-采集的数据-后羿采集器.html

Pro.ID

22706

Title

Almost the shortest rout

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22706

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/32768 K (Java/Others)
  • 描述

    N cities (2 ≤ N ≤ 10000) are connected by a network of M one-way roads (1 ≤ M < 100000000). 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 10000.

    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 ≤ K ≤ 10000).

    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.

    输入

    Input data 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.

    输出

    Description

    N cities (2 ≤ N ≤ 10000) are connected by a network of M one-way roads (1 ≤ M < 100000000). 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 10000.

    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 ≤ K ≤ 10000).

    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.

    Input

    Input data 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.

    Output

    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.

    Sample Input

    4 5 1
    1 2 1
    1 3 4
    2 3 1
    2 4 3
    3 4 1

    Sample Output

    4
    1
    3
    4
    5

    Source

    样例输入

    4 5 1
    1 2 1
    1 3 4
    2 3 1
    2 4 3
    3 4 1

    样例输出

    4
    1
    3
    4
    5

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部