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.
Hard8GeometrySortingBrute forceImplementationNo attempts yetTime limit2sMemory limit512 MBTrunk, 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 d. The wall is the region between two parallel lines at distance d. After some houses are removed, the wall separates the two remaining sets when both conditions below hold.
If d=0, 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 d separates the rest.
The input holds several test cases. The first line of each test case has three integers n, k, d, where n is the number of houses owned by citizens of Demoland, k is the number owned by citizens of Indoland, and d is the width of the wall (1≤n,k≤100, 0≤d<1000). Each of the next n lines has two integers x and y (0≤x,y≤10000), the position (x,y) of a house owned by a citizen of Demoland. The next k 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.
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.