PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FW0000099. Mua hàng trong thành phố (Shopping)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Mua hàng trong thành phố (Shopping)
Shopping
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
Home is intersection . A set of distinct stores must be visited. Roads are bidirectional and positively weighted (parallel roads may exist). Find a shortest driving route starting and ending at home and visiting every store.
Input
First , then roads (zero-based vertices). Next , then store vertices, one per line allowed.
Output
Print the minimum total 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
2 1
0 1 4
1
1
Output
8
Explanation
The sole required store is at vertex 1. The shortest tour is , totaling .