3049 - 2024_DS_Summer_Lab15 Scoreboard

Time

2024/08/08 23:24:00 2024/08/28 23:59:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14373 2024_DS_Summer_Lab15_Breakfast Transport

14373 - 2024_DS_Summer_Lab15_Breakfast Transport   

Description

In a universe beyond our own, known as the Pancake Universe, there are N breakfast shops. The coordinates of the i-th breakfast shop are (xi, yi).

The residents of the Pancake Universe have a fondness for pancakes. To facilitate a pancake exchange conference, they have decided to set up pancake teleportation gates between the breakfast shops. Specifically, there is a cost of (xi - xj)2 + (yi - yj)2 to set up a gate between the i-th and j-th breakfast shops. Once a gate is set up between two shops, the i-th shop can instantly teleport pancakes to the j-th shop, and vice versa. Once a teleportation gate is built, it can be used any number of times.

Due to financial constraints in the Pancake Universe, please help them calculate the minimum total cost required to ensure that all N breakfast shops can transport pancakes to any other shop through a series of teleportation gates.

Input

The first line contains a positive integer N.

Following that, there are N lines, each containing two integers xi and yi.

  • 1 ≤ N ≤ 10000
  • 0 ≤ xi, yi ≤ 109, ∀ i ∈ [1, N]

There could be different shops located at the same coordinates. ((xi, yi) = (xj, yj), i ≠ j)

Output

Output the answer in one line.

Sample Input  Download

Sample Output  Download

Tags




Discuss