PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000079. Đường nhanh nhất rồi ngắn nhất (New to Bangladesh?)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đường nhanh nhất rồi ngắn nhất (New to Bangladesh?)
New to Bangladesh?
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Roads carry both travel time and physical distance . For each query minimize total travel time first; among equally fast routes minimize total distance. Report both totals.
Input
First , then undirected roads (1-based), then queries .
Output
Print No Path. when unreachable, otherwise exactly Distance and time to reach destination is W & T..
Subtasks
-
Subtask 1 (40 points): . , ; .
-
Subtask 2 (60 points): . , ; .
Examples
Input
3 3 2
1 2 2 10
2 3 2 5
1 3 4 20
1 3
3 3
Output
Distance and time to reach destination is 15 & 4.
Distance and time to reach destination is 0 & 0.
Explanation
Both paths from 1 to 3 require time 4. The route via vertex 2 has distance 15 instead of 20, so it wins the secondary criterion.