#FW0000105. Lốp xe bị xì (Slow Leak)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Lốp xe bị xì (Slow Leak)
Slow Leak
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
You travel from school (intersection ) to home (intersection ). A leaky tire lasts at most distance units between repairs. Some intersections have repair stations and the school has one. Roads are bidirectional. Find the minimum total distance of a feasible journey to home; print stuck if none exists.
Input
First line , then repair-station vertices (excluding school), followed by roads , 1-indexed.
Output
Print the minimum total distance or stuck.
Subtasks
-
Subtask 1 (40 points): . All input-format and graph conditions above apply.
-
Subtask 2 (60 points): . All input-format and graph conditions above apply.
Examples
Input
3 2 1 5
2
1 2 4
2 3 4
Output
8
Explanation
Travel from 1 to station 2 (4), repair, then from 2 to home 3 (4). Each leg is at most 5, and the minimum total distance is 4+4=8.