#P16558. [ICPC 2026 LAC] Late and Disobedient

[ICPC 2026 LAC] Late and Disobedient

题目描述

Nathan is running late to the annual meeting of the Public Disobedience Association (PDA). He was driving there as fast as he could until he got stuck in front of a red light. As he is in a hurry, he wants to cross the street anyway (see Disclaimer). Of course, Nathan is not a monster, so he will cross the street only if there is enough space to cross it without hurting any pedestrian. At a given time TT, Nathan has the "feeling" that he could cross the street safely, but Nathan's feelings can be completely wrong!

The crosswalk has length LL and can be modeled as a segment on the xx-axis with endpoints at x=0x = 0 and x=Lx = L. There are NN pedestrians on the xx-axis, not necessarily on the crosswalk. Each pedestrian has an initial position XX and a constant velocity VV (positive or negative); this means that at each time t0t \ge 0 the position of the pedestrian is X+tVX + t \cdot V.

Nathan's car has width CC and he can cross the street if there is a gap of width at least CC between two consecutive pedestrians on the crosswalk or between a pedestrian and an endpoint of the crosswalk. He can also cross if there are no pedestrians on the crosswalk.

You will be given QQ queries. Each query specifies an integer time T0T \ge 0 and you must decide whether Nathan can cross the street at that moment.

Disclaimer: The organization of Programadores de América (PDA) does not condone crossing red lights nor breaking the law. This is a fictional story and the behavior of Nathan does not represent the opinions of the organization of the competition.

输入格式

The first line contains three integers NN, CC and LL (1N10001 \le N \le 1000 and 1CL1091 \le C \le L \le 10^9), indicating respectively the number of pedestrians, the width of Nathan’s car and the length of the crosswalk.

Each of the next NN lines describes a pedestrian with two integers XX and VV (109X,V109-10^9 \le X, V \le 10^9 and V0V \neq 0), representing respectively the initial position and velocity of the pedestrian. No two pedestrians have the same initial position and velocity (they differ in at least one of them).

The next line contains an integer QQ (1Q2×1061 \le Q \le 2 \times 10^6) denoting the number of queries.

Each of the next QQ lines contains an integer TT (0T1090 \le T \le 10^9) indicating the time to be considered. Times are given in increasing order.

输出格式

Output a line for each query, with the uppercase letter “Y” if Nathan can cross the street at the corresponding time, and the uppercase letter “N” otherwise.

4 5 10
1 1
9 -1
-1 -1
11 1
3
0
3
4
Y
N
Y

提示

Explanation of Sample 1:

In this sample there are N=4N = 4 pedestrians, Nathan's car has width C=5C = 5, and the crosswalk has length L=10L = 10.

At time T=0T = 0 the pedestrians are at positions x1=1x_1 = 1, x2=9x_2 = 9, x3=1x_3 = -1 and x4=11x_4 = 11, so Nathan can cross the street because there is a gap of width at least 55 between x1=1x_1 = 1 and x2=9x_2 = 9.

At time T=3T = 3 the pedestrians are at positions x1=4x_1 = 4, x2=6x_2 = 6, x3=4x_3 = -4 and x4=14x_4 = 14, so Nathan cannot cross the street because no gap is wide enough.

Finally, at time T=4T = 4 the pedestrians are at positions x1=x2=5x_1 = x_2 = 5, x3=5x_3 = -5 and x4=15x_4 = 15, so Nathan can cross the street using either the gap between x=0x = 0 and x1=x2=5x_1 = x_2 = 5, or the gap between x1=x2=5x_1 = x_2 = 5 and x=L=10x = L = 10.