#C2418. Minimum Transmission Time
Minimum Transmission Time
Minimum Transmission Time
Your network of computers is represented as an undirected weighted graph. Each computer is a node and each cable is represented by an edge with a transmission time as its weight. Given the number of computers (n), cables (m) and a list of cables, your task is to compute the minimum time required to transmit data from the starting computer to the destination computer. If no valid path exists, output (-1).
Formally, given a graph (G=(V,E)) where (|V|=n) and each edge ((u,v)) carries a weight (w), determine the shortest distance (minimum transmission time) between a given source and destination using an algorithm such as Dijkstra's algorithm.
inputFormat
Input is provided via standard input (stdin) with the following format:
- The first line contains two integers (n) and (m), representing the number of computers and cables respectively.
- The next (m) lines each contain three integers (u), (v) and (w): a cable connecting computer (u) and computer (v) with a transmission time of (w).
- The final line contains two integers, (start) and (end), specifying the source and destination computers.
outputFormat
Output a single integer to standard output (stdout) representing the minimum transmission time from the source to the destination computer. If no such path exists, output (-1).## sample
4 4
0 1 1
1 2 2
0 2 4
2 3 1
0 3
4