Given towers with unit disk coverage, place one more disk to maximize the number of towers in one connected group.
Medium7GeometryUnion-findGraphNo attempts yetTime limit3sMemory limit256 MBA cellular provider has installed n towers. Each tower covers everything within 1 km of it, and no two towers are closer than 1 km to each other. The coverage region of the network is the set of all points that lie within 1 km of at least one tower.
The provider wants as much of this region as possible to be connected. Connected means that a user at any point of a connected subregion can travel to every other point of that subregion without leaving it. The towers already installed may or may not form a single connected region. The provider has the resources to build one more tower anywhere, including within 1 km of an existing tower.
Given that one more tower is built, what is the largest number of towers, counting the new one, that can lie inside a single connected subregion of the coverage?
The first line contains one integer n, the number of towers already installed. (1≤n≤5000)
Each of the next n lines contains two space-separated real numbers xi and yi, the position of tower i in km. (0≤xi,yi≤105)
The answer is guaranteed to stay the same even if the coverage radius of every tower is increased or decreased by one millimeter.
Print on a single line one integer, the largest number of towers that can lie inside a single connected subregion of the network after one more tower is installed.