Distance to the nearest point
Time limit2sMemory limit512 MB
For each of N points, report the Manhattan distance to the nearest other point.
- Level
Hard8 of 10
- Topics
- Geometry, Divide and conquer, Sorting
- Solved
- No attempts yet
Problem
The distance between two points and is defined as follows.
You are given points . For each point , find the closest point among the others and report the distance .
Input
The first line contains the number of points ().
Each of the next lines contains the coordinates and of a point , separated by a space (). All coordinates are integers. Two or more points may have exactly the same coordinates, and the distance between such a pair is .
Output
For through , in the order given in the input, print the distance from that point to its closest point, one per line.