Finally, safety regulations require the two CLOSEST security cameras (out of hundreds placed as points on the blueprint) to be identified, so overlapping coverage can be reduced. Given N points in the plane, find the minimum Euclidean distance between any two distinct points. N can be up to 10^5 — an O(N^2) brute force is too slow; use the classic divide-and-conquer closest-pair algorithm (O(N log N)), or a sweep-line with a sorted auxiliary structure.
Input
Line1: N. Next N lines: x y.
Output
Minimum distance, 4 decimal places.
Constraints
2 ≤ N ≤ 10^5, -10^9 ≤ coords ≤ 10^9
Sample Input
4 0 0 3 4 1 1 100 100
Sample Output
1.4142
main.c
Loading editor…
Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.