gCampus (Large)
Time limit5sMemory limit512 MB
Find every road that never appears on a shortest travel-time path between any pair of offices.
- Level
Medium5 of 10
- Topics
- Shortest path, Graph
- Solved
- No attempts yet
Problem
Company G has a main campus with offices, numbered 0 to , and bidirectional roads, numbered 0 to . Road connects office and office , and travelling on it takes minutes in either direction.
A path between office and office is a sequence of one or more roads that starts at and ends at . The time taken to travel a path is the sum of the times of the roads that make it up. Every pair of offices is connected by at least one path.
Company G works on efficient transport, but the CEO has just realized that the company's own road network may be suboptimal. She wants to know which roads on the campus are inefficient. A road is inefficient if and only if it lies on no shortest path between any two offices.
Given the graph of offices and roads, find every inefficient road.
Input
The first line of the input contains the number of test cases, . test cases follow. Each case begins with a line holding two integers and , the number of offices and the number of roads. Then follow lines with three integers each, , and , meaning that road runs between office and office and takes minutes to travel.
Limits
Output
For each test case, output one line containing Case #x:, where is the test case number starting from 1. Then output the numbers of all inefficient roads in increasing order, one per line. If there is no inefficient road, output only the Case #x: line. Road 0 is the first road listed in that test case, road 1 is the second one, and so on.