Phone Cell
Time limit5sMemory limit128 MB
Given N up to 2000 points and a radius R, find the maximum number of points that a single circle of radius R can simultaneously cover.
- Level
Hard8 of 10
- Topics
- Geometry, Brute force, Math
- Solved
- No attempts yet
Problem
Cellphones can be moved (they are "mobile") and they use a wireless connection to fixed stations called BTS (Base Transceiver Station). Each BTS covers the area around it, and that area is called a cell.
A research group runs an experimental private GSM network with a BTS placed on top of a building. Because the placement of base stations is very important for network coverage, your task is to write a program that finds an optimal position for a BTS. The program is given the coordinates of several "points of interest". The goal is to find a position that covers the maximal number of these points. A BTS can cover every point that is no further than a given distance R away, so a cell has a circular shape.
For example, with eight points of interest and a suitable distance R, an optimal BTS position may cover four points, and it is not possible to cover more than four. Note that the BTS does not need to be placed exactly at an existing point of interest.
Input
The input consists of several scenarios. Each scenario begins with a line containing two integers N and R. N is the number of points of interest, 1 ≤ N ≤ 2000. R is the maximal distance the BTS is able to cover, 0 ≤ R < 10000. Then follow N lines, each containing two integers Xi, Yi giving the coordinates of the i-th point, |Xi|, |Yi| < 10000. All points are distinct; no two of them have the same coordinates.
Each scenario is followed by one empty line, and then the next scenario begins. The last one is followed by a line containing two zeros.
A point lying on the circle boundary (exactly at distance R) is considered covered. To avoid floating-point inaccuracies, the input points are chosen so that for any subset of points that can be covered by a circle of radius R + 0.001, there always exists a circle of radius R that also covers them.
Output
For each scenario, print one line: It is possible to cover M points., where M is the maximal number of points of interest that can be covered by a single BTS.