Moo Network
시간 제한4초메모리 제한1024 MB
y가 0에서 10 사이인 최대 100000개 점이 주어질 때, 제곱 유클리드 거리를 간선 가중치로 하는 최소 신장 트리의 비용을 구한다.
문제
Farmer John's cows () 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 th cow is located at a distinct location where and . The cost of building a communication link between cows and is the squared distance between them: .
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 , and the next lines each describe the and 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++).