#FW0000073. Quy hoạch giao thông (Transportation Planning)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Quy hoạch giao thông (Transportation Planning)
Transportation Planning
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
For a connected city network where each undirected road has Euclidean travel time, choose one missing road minimizing the sum of shortest travel times across all unordered pairs. Break ties by the lowest endpoint indices. Report if no addition improves the network.
Input
First , followed by integer coordinates (0-based vertices), then and undirected roads . All intersections are connected, and roads are unique.
Output
Print no addition reduces X if no improvement, otherwise adding u v reduces X to Y, where are the original and updated totals with 10 decimal digits.
Subtasks
-
Subtask 1 (40 points): . , ; tọa độ phân biệt, đồ thị liên thông.
-
Subtask 2 (60 points): . , ; tọa độ phân biệt, đồ thị liên thông.
Examples
Input
3
0 0
0 3
4 0
2
0 1
1 2
Output
adding 0 2 reduces 16.0000000000 to 12.0000000000
Explanation
Initially the three pairwise distances are 3, 5, and 8, summing to 16. Adding road 0–2 of length 4 cuts the last distance by 4 and lowers the total to 12.