#P16504. [GKS 2015 #A] gCampus
[GKS 2015 #A] gCampus
题目描述
Company G has a main campus with offices (numbered from 0 to ) and bidirectional roads (numbered from 0 to ). The th road connects a pair of offices (, ), and it takes minutes to travel on it (in either direction).
A path between two offices and is a series of one or more roads that starts at and ends at . 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?
输入格式
The first line of the input gives the number of test cases, . test cases follow. Each case begins with one line with two integers and , indicating the number of offices and roads. This is followed by lines containing three integers each: , and , indicating the th road is between office and office , and it takes minutes to travel on it.
输出格式
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:
提示
Limits
.
Small dataset (Test Set 1 - Visible)
.
.
Large dataset (Test Set 2 - Hidden)
.
.
.