CCCGuide

Problem S2: Beams of Light

2026 · S2 · Original problem · DMOJ

Problem Description

Along one wall of a parking garage there are identical parking spots numbered from 11 to NN. A collection of lights illuminates the parking garage. Each light shines on some number of adjacent parking spots.

Parking spots numbered 1 through 10 in a row from left to right. A light is above spot 1 and shines on spots 1 and 2. A second light is above spot 4 and shines on spots 2 through 6. A third light is above spot 8 and shines only on spot 8.

You will be questioned about the parking spots. For each parking spot you are questioned about, your job is to determine whether or not it is illuminated by at least one light.

Input Specification

The first line of input contains a positive integer, NN, representing the number of parking spots. The second line contains a non-negative integer, LL, representing the number of lights. The third line contains a positive integer, QQ, representing the number of parking spots you will be questioned about.

The next LL lines provide information about the LL lights. Line ii will contain two integers, PiP_i and SiS_i, separated by a single space. The first integer, 1≤Pi≤N1 \leq P_i \leq N, represents the number of the parking spot above which a light is hung. The second integer, 0≤Si≤N0 \leq S_i \leq N, represents the spread of the light's beam. Light ii shines on the parking spot that is directly below it. It also shines on the SiS_i parking spots located on either side, unless there are fewer than SiS_i spots on a side, in which case all the spots on that side will be illuminated. There could be more than one light directly above a parking spot.

The next QQ lines of input each contain a positive integer between 11 and NN inclusive, representing the number of the parking spot you are questioned about.

The following table shows how the 1515 available marks are distributed:

MarksNumber of SpotsNumber of LightsNumber of Questions
11N≤50N \leq 50L≤1L \leq 1Q≤50Q \leq 50
22N≤50N \leq 50L≤50L \leq 50Q≤50Q \leq 50
33N≤50N \leq 50L≤500 000L \leq 500\,000Q≤500 000Q \leq 500\,000
99N≤500 000N \leq 500\,000L≤500 000L \leq 500\,000Q≤500 000Q \leq 500\,000

Output Specification

There will be one line of output for each of the QQ parking spots you are questioned about.

On each of these lines, output Y if the corresponding parking spot is illuminated by at least one light, or N if the corresponding parking spot is not illuminated by any light.

Sample Input

10
3
4
8 0
1 1
4 2
4
10
7
1

Output for Sample Input

Y
N
N
Y

Explanation of Output for Sample Input

The input describes the following picture of the parking garage.

Parking spots numbered 1 through 10 in a row from left to right. A light is above spot 1 and shines on spots 1 and 2. A second light is above spot 4 and shines on spots 2 through 6. A third light is above spot 8 and shines only on spot 8.

Parking spots 44 and 11 are illuminated by at least one light.

Parking spots 1010 and 77 are not illuminated by any light.