Answer to Question #44995 in C for Palak

Question #44995
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"

Constraints:
1<=N<=350

1<=M<=N*(N-1)

1<=K<=N

1<=I<=N

0<=V<=500

1<=Source<=N

1<=Destination<=N

1<=Distance<=200


Sample Input and Output

SNo. Input Output
1
3 3 1 2 10
1 2 5
2 3 5
1 3 12
2 3


Yes



Explanation:

Locations 2 is directly reachable through an edge of weight (distance) 5 units.

Node 3 is reachable through edges 1-> 2 and 2-> 3 of weights 5 units each.

Hence node 3 is reachable fr
0
Expert's answer

Answer in progress...

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
05.08.15, 15:18

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

LATEST TUTORIALS
APPROVED BY CLIENTS