#C8115. Highest Minimum Link Reliability Path
Highest Minimum Link Reliability Path
Highest Minimum Link Reliability Path
You are given a network of n computers and m bidirectional links. Each link between two computers has a reliability value. The reliability of a path is defined as the minimum reliability among all links on that path. Your task is to find the path from a given source to a destination computer that maximizes this minimum link reliability. If no path exists, output -1.
More formally, given a graph \(G = (V, E)\) where each edge \((u,v)\) has a reliability \(w\), find a path \(P\) from the source vertex \(s\) to the destination vertex \(t\) such that the value \[ R(P) = \min_{(u,v)\in P} w(u,v) \] is maximized. Output the value of \(R(P)\) if such a path exists, otherwise output -1.
inputFormat
The first line contains two integers n and m, representing the number of computers and the number of links respectively.
The next m lines each contain three integers u, v, and w, indicating there is a bidirectional link between computer u and computer v with reliability w.
The last line contains two integers source and destination, representing the starting and target computers.
Note: Input is read from stdin
.
outputFormat
Output a single integer: the highest minimum link reliability for a path from the source to the destination. If no such path exists, output -1.
Note: Output should be written to stdout
.
5 6
1 2 10
1 3 5
2 3 7
2 4 10
3 4 8
4 5 9
1 5
9