#FW0000114. Giảm chi phí giao hàng (Reducing Delivery Cost)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Giảm chi phí giao hàng (Reducing Delivery Cost)
Reducing Delivery Cost
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A connected weighted undirected graph has districts and roads with positive costs. There are delivery requests , independently choosing a minimum-cost route; requests may repeat or have . You may reduce the cost of at most one existing road to zero in both directions. Minimize the sum of shortest travel costs over all requests.
Input
First line: ; then lines ; then requests . Vertices are -indexed.
Output
Print the minimum total cost.
Subtasks
-
Subtask 1 (40 points): , , , . All input conditions remain in force.
-
Subtask 2 (60 points): , , , . All input conditions remain in force.
Examples
Input
6 5 2
1 2 5
2 3 7
2 4 4
4 5 2
4 6 8
1 6
5 3
Output
22
Explanation
Making either road (2,4) or (4,6) free reduces the total shortest delivery cost to 22.