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 Format:
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
Output Format:
Print "Yes" if all K nodes are reachable without travelling a distance greater than V else print "No"
Dear Palak Questions in this section are answered for free. We can't
fulfill them all and there is no guarantee of answering certain
question but we are doing our best. And if answer is published
it means it was attentively checked by experts. You can try it
yourself by publishing your question. Although if you have serious
assignment that requires large amount of work and hence cannot be
done for free you can submit it as assignment and our experts will
surely assist you
Leave a comment
Thank you! Your comments have been successfully added. However, they need to be checked by the moderator before being published.
Comments
Dear Palak Questions in this section are answered for free. We can't fulfill them all and there is no guarantee of answering certain question but we are doing our best. And if answer is published it means it was attentively checked by experts. You can try it yourself by publishing your question. Although if you have serious assignment that requires large amount of work and hence cannot be done for free you can submit it as assignment and our experts will surely assist you
Leave a comment