#FW0000074. Chiến tranh và hậu cần (Warfare And Logistics)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Chiến tranh và hậu cần (Warfare And Logistics)
Warfare And Logistics
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
An undirected logistics network has a positive cost on each edge. The cost for an ordered pair is its shortest-path cost, or if unreachable. Compute the total before an attack and the maximum total obtained by deleting exactly one individually indexed road.
Input
First , then undirected weighted roads using 1-based indices. Parallel roads are allowed.
Output
Print two integers: the total before deletion and the maximum total after one deletion.
Subtasks
-
Subtask 1 (40 points): . , ; đường vô hướng, có thể có cạnh trùng.
-
Subtask 2 (60 points): . , ; đường vô hướng, có thể có cạnh trùng.
Examples
Input
3 3 100
1 2 2
2 3 3
1 3 10
Output
20 52
Explanation
Original distances over unordered pairs are 2, 3, and 5; ordered-pair sum is 20. Removing road 1–2 changes them to 13, 3, and 10, for a total of 52.