Escape from the Minefield
Time limit2sMemory limit512 MB
Each mine kills within 2 meters; find the largest disk centered at the origin (radius r) that can slide clear of all mines, then output floor(pi r^2).
- Level
Hard8 of 10
- Topics
- Geometry, Graph, BFS, Binary search
- Solved
- No attempts yet
Problem
After a failed parachute drop, Lieutenant Jones and his platoon land in the middle of an enemy minefield instead of at their target coordinates.
Jones carries an accurate map showing the location of every mine. Each anti-personnel mine has a blast-and-detection radius of meters: anyone who comes within meters of a mine dies.
For the moment the platoon is safe, hidden beneath a bush at Jones' position. They will escape in a single circular formation: a disk of radius centered on the bush. Each soldier needs square meter of area on average, so a formation of radius can hold soldiers.
The formation must stay outside every mine's blast radius at all times. That is:
- At the start, the whole disk (centered on the bush) must lie at least meters away from every mine.
- To escape, the disk must be able to move from the bush all the way out of the field, and at every moment no point of the disk may come within meters of any mine (the disk has to squeeze through the gaps between mines).
Jones wants to bring out as many soldiers as possible; anyone who does not fit inside the largest formation that can safely escape is left behind to be captured. Determine that maximum number of soldiers.
Input
The first line contains a positive integer , the number of test cases. Each test case is given as follows:
- A line with a single positive integer (), the number of mines.
- lines follow, each with two integers and (): the coordinates in meters of a mine relative to Jones' position (the bush is at the origin). No two mines share the same coordinates.
Output
For each test case, output a single line containing one integer: the maximum number of soldiers that can escape.