atcoder#ABC250H. [ABC250Ex] Trespassing Takahashi
[ABC250Ex] Trespassing Takahashi
Score : points
Problem Statement
There are points numbered through , and roads. The -th () road connects Point and Point bidirectionally and requires minutes to pass through. One can travel from any point to any other point using some number of roads. There is a house on Points .
For , solve the following problem.
Takahashi is currently at the house at Point and wants to travel to the house at Point . Once minutes have passed since his last sleep, he cannot continue moving anymore. He can get sleep only at a point with a house, but he may do so any number of times. If he can travel from Point to Point , print
Yes
; otherwise, printNo
.
Constraints
- $N-1 \leq M \leq \min (2 \times 10^5, \frac{N(N-1)}{2})$
- If , then .
- One can travel from any point to any other point using some number of roads.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the answer for the -th problem.
6 6 3
1 4 1
4 6 4
2 5 2
3 5 3
5 6 5
1 2 15
3
2 3 4
2 3 5
1 3 12
No
Yes
Yes
In the -rd problem, it takes no less than minutes from Point to reach Point directly. However, he can first travel to Point in minutes, get sleep in the house there, and then travel to Point . Thus, the answer is Yes
.