PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000111. Chuyến du lịch của Joisino (joisino’s travel)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Chuyến du lịch của Joisino (joisino’s travel)
joisino’s travel
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
An undirected weighted road network has cities. Choose an order to visit designated cities. Flying to the first one and back from the last one costs no road distance; travel between successive designated cities must use roads. Minimize total road distance.
Input
First line , then designated cities, then roads .
Output
Print minimum total road distance.
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 2
1 3
1 2 2
2 3 3
Output
5
Explanation
The required cities are 1 and 3. Their shortest route passes through city 2 with distance . Reversing their visit order has the same cost.