#C2909. Sensor Coverage Analysis

    ID: 46277 Type: Default 1000ms 256MiB

Sensor Coverage Analysis

Sensor Coverage Analysis

In this problem, you are given a rectangular area with width \(W\) and height \(H\). There are \(N\) sensors placed at specified coordinates, and each sensor covers a circular area of radius \(R\). A point \( (x, y) \) inside the rectangle is said to be covered by a sensor located at \( (s_x, s_y) \) if the Euclidean distance from the sensor to the point satisfies \(\sqrt{(x - s_x)^2 + (y - s_y)^2} \le R\).

Your goal is to determine whether every integer coordinate point between \(0\) and \(W\) (inclusive) in the x-direction and between \(0\) and \(H\) (inclusive) in the y-direction is covered by at least one sensor.

The input consists of multiple test cases. Each test case begins with a line containing four space-separated integers \(W\), \(H\), \(N\), and \(R\). This is followed by \(N\) lines, each containing two integers, representing the coordinates of a sensor. The input terminates with a single line containing the integer 0.

For each test case, print a line indicating the test case number and whether the area is completely covered by the sensors. Format the output as "Case i: Yes" if all points are covered, and "Case i: No" otherwise, where \(i\) is the test case number.

inputFormat

The input is read from standard input (stdin) and consists of multiple test cases:

  • The first line of a test case contains four space-separated integers: \(W\) \(H\) \(N\) \(R\).
  • The next \(N\) lines each contain two space-separated integers representing a sensor's coordinates \(s_x\) and \(s_y\).
  • The input ends with a line containing a single 0.

outputFormat

For each test case, output a single line to standard output (stdout) in the following format:

Case i: Yes if the rectangular area is completely covered by the given sensors, or Case i: No otherwise, where \(i\) is the test case number.

## sample
5 5 4 2
1 1
1 4
4 1
4 4
0
Case 1: Yes

</p>