#FW0000072. Xây dựng đường mới (Road Construction)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Xây dựng đường mới (Road Construction)
Road Construction
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Cities are points in the plane, with existing undirected roads weighted by Euclidean length. Add at most one missing road to maximize the decrease in the sum of shortest distances over unordered city pairs. Improvement must exceed . Ties favor the shorter proposed road, then lexicographically smaller endpoints.
Input
First ; then integer coordinate pairs and existing undirected edges (1-based). The initial graph is connected without duplicate edges.
Output
Print u v (with ) for the chosen road, or No road required.
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 2
0 0
0 3
4 0
1 2
2 3
Output
1 3
Explanation
The original route 1–2–3 costs 8. Adding the straight 1–3 road costs 4 and improves the total by 4, which exceeds the required threshold.