Lifting Walls
InterviewTime limit1sMemory limit256 MB
Choose the fewest of up to 30 crane sites so that each of the four wall centers is within reach of a chosen crane.
- Level
Easy3 of 10
- Topics
- Brute force, Geometry
- Solved
- No attempts yet
Problem
A construction firm is putting up an apartment building. The walls are made in advance and lifted into place with cranes. The firm has found possible crane locations and wants to pick some of them so that the center of each of the four walls is reached by at least one crane. Cranes are expensive, so the firm wants to use as few as possible. A crane reaches a wall if the distance from the crane to that wall's center is at most .
The house is a rectangle with length and width .
Find the minimum number of cranes needed to reach the centers of all four walls.

The figure shows the layout of the first example.
Input
The first line contains four space separated integers , , and , all positive and at most 30. and are the length and the width of the house, is the number of possible crane locations, and is the reaching distance of a crane.
Each of the next lines contains two integers and (), one possible crane location per line. The origin of the coordinate system is the center of the building and the axis runs along the length of the house, so the wall centers are at , , and .
Output
Print the minimum number of cranes needed to reach the centers of all four walls. If no choice of cranes reaches all four wall centers, print Impossible.