#P7883. 平面最近点对(加强加强版)
平面最近点对(加强加强版)
Background
The highest-upvoted solution for P1429 Closest Pair of Points on a Plane (Enhanced Version) says:
We fully carry forward human wisdom:
Rotate all points by the same angle around the origin, then sort by the coordinate.
By mathematical intuition, after a random rotation, the two points in the answer will surely not be too far apart in the array.
So we only take the next points for each point to compute the answer.
This becomes extremely fast; even for it can pass within 1 second.
Of course, this is wrong.
Problem Description
Given points in a 2D Euclidean plane, output the squared distance between the closest pair of points.
Input Format
The first line contains a positive integer , the number of points.
The next lines each contain two integers separated by spaces, representing .
The input guarantees that no two points have exactly the same coordinates.
Output Format
Output one line containing an integer , the square of the distance between the closest pair of points.
Since all input points have integer coordinates, this value must be an integer.
2
-10000000 -10000000
10000000 10000000
800000000000000
5
1 1
1 9
9 1
9 9
0 10
2
Hint
For the second sample, the points and are the closest, with distance , so you should output .
Constraints
For of the testdata, , .
The target complexity of this problem is . The reason for setting the time limit to 350 ms is:
- A reference implementation of will not TLE even when using
cin. The fastest standard solution can be 100 ms. - @wlzhouzhuan's program can run exactly checks within 350 ms.
- There are 150 test cases, to prevent people from exploiting the judge.
On 2025.2.6, three hack test cases were added (Credit to
Translated by ChatGPT 5