#K69317. Ant Communication Threshold

    ID: 33060 Type: Default 1000ms 256MiB

Ant Communication Threshold

Ant Communication Threshold

In this problem, you are given an ant colony network represented as a directed weighted graph. Each vertex represents an ant, and each edge represents a communication link with a reliability score. The task is to determine whether there exists a path from a starting ant (s) to a target ant (t) such that the sum of the reliability scores along the path does not exceed a given threshold (k).

Formally, you are given three integers (n, m, k) where (n) is the number of ants (nodes), (m) is the number of communication links (edges), and (k) is the maximum allowable reliability score. Then you are given (m) edges, each represented by three integers (u, v, w) meaning there is a directed edge from ant (u) to ant (v) with a reliability score (w). Finally, you are given two integers (s) and (t) representing the starting ant and the target ant respectively.

You need to determine if there exists a path from (s) to (t) such that the total reliability score is (\le k). If such a path exists, output "Yes", otherwise output "No".

inputFormat

The first line contains three integers (n), (m), and (k), where (n) is the number of ants, (m) is the number of communication links, and (k) is the maximum allowable reliability score. The next (m) lines each contain three integers (u), (v), and (w) representing a communication link from ant (u) to ant (v) with reliability score (w). The last line contains two integers (s) and (t), the starting and target ants respectively.

outputFormat

Output a single line containing either "Yes" if there exists a path from ant (s) to ant (t) with the total reliability score less than or equal to (k), or "No" otherwise.## sample

5 6 5
1 2 2
1 3 1
2 4 2
3 4 3
4 5 1
3 5 1
1 5
Yes

</p>