Disposable Switches
Time limit4sMemory limit512 MB
Find the switches that never lie on an optimal path from switch 1 to switch n, whatever the cable speed and per-cable overhead turn out to be.
- Level
Hard8 of 10
- Topics
- Graph, Shortest path, Geometry
- Solved
- No attempts yet
Problem
You were recently hired by Netwerc Industries as a network engineer. Your first task is to assess their large, dated office network. You have mapped the network, which consists of switches and the cables between them. You suspect that some switches are redundant and that others are not used at all. Before you present this to your boss, you decide to write a program to test the claim.
The data consists of the network map and the length of each cable. A packet sent across a cable of length takes time
where is the propagation speed of the cable and is the overhead of transmitting the packet on and off the cable. The values of and are unknown. You only know that they are real numbers with and , and that they are the same for all cables. Network routing ensures that a packet takes an optimal path, meaning a path that minimizes the total transit time.
Given the network map and the cable lengths, determine which switches can never be part of an optimal path from switch 1 to switch , no matter what the values of and are.
Input
The first line has two integers and (, ), the number of switches and cables. The switches are numbered 1 to . Each of the next lines has three integers , , and (, ), describing a cable of length between switches and . At most one cable connects any pair of switches, and no cable connects a switch to itself. There is a path between every pair of switches.
Output
First output a line with an integer , the number of switches that can never be part of an optimal path from switch 1 to switch . Then output a line with the indices of these switches in increasing order.