Punching Power
Time limit2sMemory limit512 MB
Choose the largest subset of given grid points so every pair is more than 1.3 meters apart.
- Level
Medium6 of 10
- Topics
- Graph, Greedy, Geometry, Brute force
- Solved
- No attempts yet
Problem
The park management decided to install boxing machines at several places in the park. Machines have been in short supply, so this time they want to put up as many as they can. The park will still not fill up with machines, because the legal limits on where a machine may stand are strict.
The management marked every possible machine position on the park plan and wrote down its coordinates. The manufacturer's safety rule applies as well. The distance between any two boxing machines is at least meters.
Find the largest number of boxing machines that can be installed without breaking that rule.
Input
The input holds several test cases. The first line of each test case has one integer , the number of possible machine positions in the park (). Each of the next lines describes one position with two integer coordinates in meters. Every coordinate is at least and at most . The same coordinate pair never appears twice inside one test case.
The positions of one test case form a single connected group. Starting from any position you can reach every other position by steps that change exactly one coordinate by and always land on a position where a machine may stand.
There are at most test cases, and the sum of over all test cases is at most . The input ends at end of file.
Output
For each test case, print one line with the largest number of boxing machines that can be installed.