Answer to Question #53957 in Other Engineering for sarankumar
There are N nodes in a graph. The graph is unidirectional with M edges. Of these N nodes in the graph, there are K nodes which are important nodes. Given initial position I, within this graph, the task is to find out, if all K nodes are reachable without travelling a distance greater than V from I.
Input consists of:
First line starts with N, M, I, K and V
Next M lines follow; each contains (Source, Destination, and Distance).
Next line contains K spaced important nodes
Print "Yes" if all K nodes are reachable without travelling a distance greater than V else print "No"
Sample Input and Output
SNo. Input Output
3 3 1 2 10
1 2 5
2 3 5
1 3 12