#abc250h. Ex - Trespassing Takahashi
Ex - Trespassing Takahashi
Score : points
问题描述
有 个编号为 到 的点,以及 条道路。第 条()道路在点 和点 之间双向连接,并且需要 分钟通过。使用一些数量的道路可以从任意一个点到达另一个点。在点 上有房子。
对于 ,解决以下问题:
高桥当前位于编号为 的房子处,他想要前往编号为 的房子处。
自从他上次睡觉后经过了 分钟,他就无法再继续移动。
他只能在有房子的点上睡觉,但可以任意次数地进行休息。
如果他可以从点 到达点 ,则输出Yes
;否则,输出No
。
以上为通义千问 qwen-max 翻译,仅供参考。
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 , printYes
; 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.
Sample Input 1
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
Sample Output 1
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
.
update @ 2024/3/10 10:42:13