Border Wall
Time limit2sMemory limit512 MB
Given two colored point sets and a width d, find the minimum number of points to delete so that a strip of width d separates the remaining points by color.
- Level
Hard8 of 10
- Topics
- Geometry, Sorting, Brute force, Implementation
- Solved
- No attempts yet
Problem
Trunk, the new president of Demoland, promised during his campaign to build a wall along the border with the neighboring country Indoland. The wall follows one straight line. The trouble is that the houses of the two nations are mixed together, so no straight line splits them cleanly. Wherever the wall goes, some houses must be evacuated and their residents moved to the other side. The wall also has a width, so every house that overlaps it must be destroyed. Evacuating or destroying a house costs money, and a large number of such houses brings loud protest. The president wants to know the smallest number of houses that must be evacuated or destroyed for a wall of the width he wants.
The houses of each nation are given as a set of points in the plane, together with the wall width . The wall is the region between two parallel lines at distance . After some houses are removed, the wall separates the two remaining sets when both conditions below hold.
- No two houses of different nations lie on the same side of the wall.
- No house lies inside the wall. A house on either boundary line is allowed.
If , the two boundary lines coincide, the wall is a single line, and a house on that line lies on neither side. Removing every house of one nation is allowed. Compute the minimum number of points that must be removed so that a wall of width separates the rest.
Input
The input holds several test cases. The first line of each test case has three integers , , , where is the number of houses owned by citizens of Demoland, is the number owned by citizens of Indoland, and is the width of the wall (, ). Each of the next lines has two integers and (), the position of a house owned by a citizen of Demoland. The next lines give the positions of the houses owned by citizens of Indoland in the same format. No two houses share a position. The input ends with a line holding 0 0 0, which is not processed.
Output
For each test case, print one line with the minimum number of houses that must be removed to build the wall. In an optimal solution every house of one nation may be removed.