#BS0000440. Mạng liên lạc của đàn bò (Moocast)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Mạng liên lạc của đàn bò (Moocast)
Moocast
Source: USACO
Version: Phuoc Hung OJ Extended
Problem Statement
Farmer John has cows, numbered from to . Cow occupies the integer-coordinate point in the plane. Each cow will receive the same type of radio.
At a nonnegative integer cost per radio, its transmission radius is . Cows can communicate directly in either direction precisely when
A cow receiving a message can relay it to other cows within radio range. Messages may therefore travel through intermediate cows.
Find the least integer cost for which a message originating at any cow can eventually reach every other cow.
Input
- The first line contains an integer , the number of cows.
- The next lines each contain two integers , the coordinates of cow .
Output
Print one nonnegative integer: the minimum cost satisfying the requirement.
Subtasks
- Subtask 1 (20 points): ; for all .
- Subtask 2 (30 points): ; for all . for all .
- Subtask 3 (50 points): ; for all .
Examples
Example 1
Input
4
1 3
5 4
7 2
6 1
Output
17
Explanation
The squared distances of pairs ; ; and are , , and , respectively. At , this chain connects all cows. Cow has squared distances and to cows and ; below it is isolated. Therefore the minimum is .
