PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000227. Nối các hòn đảo (Island Hopping)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Nối các hòn đảo (Island Hopping)
Island Hopping
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
There are islands with coordinates . You may build straight bridges between any two islands, with cost proportional to Euclidean length. All islands must become mutually reachable through bridges.
Determine the minimum total length of bridges, where the length between two islands is .
Input
- The first line contains integer .
- Each of the next lines contains integer coordinates for an island. All positions are distinct.
Output
Print the minimum total bridge length, with 10 digits after the decimal point.
Subtasks
- Subtask 1 (20 points): ; ; mọi cặp tọa độ phân biệt.
- Subtask 2 (30 points): ; ; mọi cặp tọa độ phân biệt.
- Subtask 3 (50 points): ; ; mọi cặp tọa độ phân biệt.
Examples
Input
3
0 0
0 3
4 0
Output
7.0000000000
Explanation
The pairwise distances are between islands , between , and between . The two bridges of lengths and connect all islands for total length .