Problem list
Log in
#r03624 · CCC 2026 Junior

Beams of Light

Unrated 2.0 s 256 MB

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

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

The first line of input contains a positive integer, $N$, representing the number of parking spots. The second line contains a non-negative integer, $L$, representing the number of lights. The third line contains a positive integer, $Q$, representing the number of parking spots you will be questioned about.

The next $L$ lines provide information about the $L$ lights. Line $i$ will contain two integers, $P_i$ and $S_i$, separated by a single space. The first integer, $1 \leq P_i \leq N$, represents the number of the parking spot above which a light is hung. The second integer, $0 \leq S_i \leq N$, represents the spread of the light's beam. Light $i$ shines on the parking spot that is directly below it. It also shines on the $S_i$ parking spots located on either side, unless there are fewer than $S_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 $Q$ lines of input each contain a positive integer between $1$ and $N$ inclusive, representing the number of the parking spot you are questioned about.

Output

There will be one line of output for each of the $Q$ 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.

Constraints

$1 \leq P_i \leq N$ $0 \leq S_i \leq N$

Example 1

Input
10
3
4
8 0
1 1
4 2
4
10
7
1
Output
Y
N
N
Y

The input describes the following picture of the parking garage.

Parking spots (4) and (1) are illuminated by at least one light.

Parking spots (10) and (7) are not illuminated by any light.

Source
CCC 2026 Junior
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code