#P16504. [GKS 2015 #A] gCampus

    ID: 18879 远端评测题 1000ms 1024MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>图论2015最短路Floyd 算法Google Kick Start

[GKS 2015 #A] gCampus

Problem Description

Company G has a main campus with NN offices (numbered from 0 to N1N - 1) and MM bidirectional roads (numbered from 0 to M1M - 1). The iith road connects a pair of offices (UiU_i, ViV_i), and it takes CiC_i minutes to travel on it (in either direction).

A path between two offices XX and YY is a series of one or more roads that starts at XX and ends at YY. The time taken to travel a path is the sum of the times needed to travel each of the roads that make up the path. (It's guaranteed that there is at least one path connecting any two offices.)

Company G specializes in efficient transport solutions, but the CEO has just realized that, embarrassingly enough, its own road network may be suboptimal! She wants to know which roads in the campus are inefficient. A road is inefficient if and only if it is not included in any shortest paths between any offices.

Given the graph of offices and roads, can you help the CEO find all of the inefficient roads?

Input Format

The first line of the input gives the number of test cases, TT. TT test cases follow. Each case begins with one line with two integers NN and MM, indicating the number of offices and roads. This is followed by MM lines containing three integers each: UiU_i, ViV_i and CiC_i, indicating the iith road is between office UiU_i and office ViV_i, and it takes CiC_i minutes to travel on it.

Output Format

For each test case, output one line containing "Case #x:", where x is the test case number (starting from 1). Then output the road numbers of all of the inefficient roads, in increasing order, each on its own line. (Note that road 0 refers to the first road listed in a test case, road 1 refers to the second road, etc.)

2
3 3
0 1 10
1 2 3
2 0 3
3 3
0 1 10
1 2 3
2 1 3
Case #1: 
0
Case #2:

Hint

Limits

0<Ci10000000 < C_i \le 1000000.

Small dataset (Test Set 1 - Visible)

1T101 \le T \le 10.

1N=M1001 \le N = M \le 100.

Large dataset (Test Set 2 - Hidden)

1T31 \le T \le 3.

1N1001 \le N \le 100.

1M100001 \le M \le 10000.