#BS0000357. Phủ điểm qua đường thẳng (Underwater Snipers)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Phủ điểm qua đường thẳng (Underwater Snipers)
Underwater Snipers
Source: ICPC Live Archive
Version: Phuoc Hung OJ Extended
Problem Statement
The horizontal line divides the coordinate plane into two halves. There are points above it; point has coordinates .
Place centers of circles of radius strictly below the line, so every center has a y-coordinate smaller than . Both the given points and the centers have integer coordinates. Once placed, the centers remain fixed. A point is covered when its Euclidean distance to at least one center is at most .
Let be the smallest distance from any center to the line . Find the maximum possible such that all given points are covered, or report that no placement exists.
Input
The first line contains four integers : the line height, number of points, number of centers and radius. Each of the next lines gives two integers , the coordinates of point .
Output
Print one integer, the maximum possible , or IMPOSSIBLE if no placement exists.
Subtasks
- Subtask 1 (20 points): ; ; ; , for every .
- Subtask 2 (30 points): ; ; ; , for every .
- Subtask 3 (50 points): ; ; ; , for every .
Examples
Input 1
0 3 2 4
1 1
3 2
9 1
Output 1
2
Explanation 1
At height -2 the centers (3,-2) and (9,-2) cover all three points, with squared distances 13, 16 and 9 respectively. A depth of at least 3 would leave the point (3,2) at vertical distance at least 5, exceeding the radius 4. Thus 2 is optimal.
Input 2
0 3 1 4
1 1
3 2
9 1
Output 2
IMPOSSIBLE
Explanation 2
Only one center is allowed. The points (1,1) and (9,1) are eight units apart. A radius-four circle containing both must be centered at their midpoint (5,1), which lies above the line and is invalid.