Distance Between the Closest Pair of Points
Time limit1sMemory limit256 MB
Given up to 500,000 distinct points, find the two closest and print the square of their distance.
- Level
Medium7 of 10
- Topics
- Divide and conquer, Sorting, Geometry, Binary search
- Solved
- No attempts yet
Problem
There are points on a plane. Among these points, find the two that are closest to each other and determine the distance between them.
Input
The first line contains the number of points .
Each of the next lines, from the 2nd line through the -th line, contains the coordinates and of a single point separated by a space. The values on the -th line are the - and -coordinates of point .
Constraints: and . All points have distinct coordinates (no two points share the same coordinates).
Output
Print the square of the distance between the closest pair of points.