아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Moo Network

시간 제한4초메모리 제한1024 MB

요약
y가 0에서 10 사이인 최대 100000개 점이 주어질 때, 제곱 유클리드 거리를 간선 가중치로 하는 최소 신장 트리의 비용을 구한다.
난이도

보통10점 중 7점

유형
최소 신장 트리, 그래프, 정렬
정답자
아직 제출이 없습니다

문제

Farmer John's NN cows (1≤N≤1051 \leq N \leq 10^5) are spread far apart on his farm and would like to build a communication network so they can more easily exchange electronic text messages (all of which of course contain variations of "moo").

The iith cow is located at a distinct location (x_i,y_i)(x\_i,y\_i) where 0≤x_i≤1060 \leq x\_i \leq 10^6 and 0≤y_i≤100 \leq y\_i \leq 10. The cost of building a communication link between cows ii and jj is the squared distance between them: (x_i−x_j)2+(y_i−y_j)2(x\_i-x\_j)^2 + (y\_i-y\_j)^2.

Please calculate the minimum cost required to build a communication network across which all the cows can communicate. Two cows can communicate if they are directly connected by a link, or if there is a sequence of links along which their message can travel.

입력

The first line of input contains NN, and the next NN lines each describe the xx and yy coordinates of a cow, all integers.

출력

Please output the minimum cost of a network that will allow all cows to communicate. Note that this cost might be too large to fit into a 32-bit integer and may require use of 64-bit integers (e.g., "long long" integers in C++).

예제1

  1. 예제 1

    입력
    10
    83 10
    77 2
    93 4
    86 6
    49 1
    62 7
    90 3
    63 4
    40 10
    72 0
    
    예상 출력
    660