SAC '22 Code Challenge 5 P4 - Querying Intervals

View as PDF

Submit solution


Points: 10 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

Since Mr. DeMello hates flavour text, he decides to give you a sleek statement instead:

Given N intervals of [li,ri], answer Q queries.

Each query comes in the form L_i R_i, where you will check if you can move from Li to Ri while always being on an interval (i.e., every integer on that interval must be contained in at least one of the N intervals).

Output Y if you can cover the range [Li,Ri]; otherwise, output N if you cannot cover the range.

Can you help Mr. DeMello?

Constraints

1N,Q100000

109liri109

109LiRi109

Input Specification

The first line will contain two integers, N and Q, the number of intervals and the number of queries, respectively.

The next N lines will contain two integers, li and ri, the endpoints of the ith interval.

The next Q lines will contain two integers, Li and Ri, the endpoints of the ith query.

Output Specification

Output Q lines, the answers to the queries.

Sample Input

Copy
4 3
7 9
-5 4
10 14
16 19
8 10
-5 -5
11 18

Sample Output

Copy
Y
Y
N

Comments


  • 0
    ColonelBy_team10  commented on Aug. 26, 2022, 12:37 a.m.

    Is there any overlaps in the intervals?