Skip to main content

Practice · 3 of 3

Closest Pair

CHALLENGE
Difficulty: advanced+25 XP

**Problem.** Line 1: n. Then n points. Print the SQUARED distance of the closest pair. **Constraints:** 2 ≤ n ≤ 100000; 0 ≤ x, y ≤ 10^9 (squared distances fit in long long). Divide & conquer; the all-pairs W is O(n^2) — timeout.

Back to lesson: Practice: Geometry Suite