Range Closest Pair of Points Query
Time limit9sMemory limit1024 MB
Given n points and q index ranges [l, r], find the squared distance of the closest pair of points inside each range.
- Level
Hard9 of 10
- Topics
- Divide and conquer, Geometry, Sorting
- Solved
- No attempts yet
Problem
The closest pair of points problem is a well-known problem of computational geometry. There are points in the Euclidean plane. You are given queries. The -th query gives two integers and (). For each query, find a pair of points with such that the Euclidean distance between and is minimized.
Input
The first line contains two integers and (, ), the number of points and the number of queries.
Each of the next lines contains two integers and (), the coordinates of .
Each of the next lines contains two integers and (), describing a query.
Output
For each query, print one line containing the value for the closest pair in the range.