Nearest Points
Time limit2sMemory limit512 MB
Count the integer lattice points in an axis-aligned rectangle whose Euclidean distance to p1 is the minimum among K marked points.
- Level
Hard9 of 10
- Topics
- Geometry, Divide and conquer, Sorting, Combinatorics
- Solved
- No attempts yet
Problem
On the Cartesian plane, let be a rectangle with sides parallel to the axes and vertices at and , where and are positive integers. Inside this rectangle (including the boundary) there are points with integer coordinates. A point in with integer coordinates is called good if the distance from to is no greater than the distance from to any of the points , .
How many good points are there?
Input
The first line contains three positive integers , , , : the dimensions of the rectangle and the number of marked points. The -th of the following lines () contains two integers , (, ): the coordinates of the -th point. All points are distinct.
Output
Print a single nonnegative integer: the answer.