Mine Clearing
Time limit10sMemory limit512 MB
Find the most mines covered by one axis-aligned 10 by 10 square placed anywhere on the site.
- Level
Medium6 of 10
- Topics
- Sliding window, Sorting, Segment tree
- Solved
- No attempts yet
Problem
A new mine clearing machine has arrived at the site. One activation removes every mine inside a 10m × 10m square at once, and mines lying on the border of that square are removed as well. Two sides of the square are parallel to the x-axis and the other two are parallel to the y-axis, and the machine can be placed anywhere on the site.
The positions of all mines buried in the 10,000m × 10,000m site are known. Write a program that finds the largest number of mines one activation can remove.
Input
The first line contains the number of test cases ().
The first line of each test case contains the number of mines (), and the next lines give the coordinates of the mines, one mine per line. Each of those lines holds two integers between and separated by a single space, the x-coordinate first and the y-coordinate second. No two mines sit at the same coordinates, and a mine is small enough that its size can be ignored.
Output
For each test case, print on its own line the largest number of mines one activation can remove.