AdvancedRating 1600
Signal Delay
A signal starts at node k in a directed weighted network ('u v t' means u→v takes t). Print the time until every node has the signal, or -1.
Input
n m k, then m lines.
Output
A number.
Sample 1
Input
4 3 2 2 1 1 2 3 1 3 4 1
Output
2
Sample 2
Input
2 1 1 1 2 1
Output
1
Output appears here