#K33952. Non-overlapping Planting Sections

    ID: 25201 Type: Default 1000ms 256MiB

Non-overlapping Planting Sections

Non-overlapping Planting Sections

In a terrarium, there are designated sections occupied by plants. In this problem, you are given a list of sections, each represented as an interval [Li,Ri][L_i, R_i]. You are also given a list of query intervals [Lq,Rq][L_q, R_q]. For each query interval, determine whether it is free of any overlap with the pre-defined sections. Two intervals [Li,Ri][L_i, R_i] and [Lq,Rq][L_q, R_q] are said to overlap if they satisfy $$L_q \le R_i \quad\text{and}\quad R_q \ge L_i.$$

If a query interval does not overlap any existing section, output "Yes"; otherwise, output "No". All comparisons are inclusive. This problem tests your ability to perform interval comparisons and handle multiple queries efficiently.

inputFormat

The first line contains two integers NN and QQ, where NN is the number of pre-defined sections and QQ is the number of queries. The next NN lines each contain two integers LiL_i and RiR_i representing the start and end points of the sections. This is followed by QQ lines, each containing two integers LqL_q and RqR_q for the query intervals.

outputFormat

For each query interval, output a single line containing either "Yes" if the interval does not overlap with any section, or "No" if it does.## sample

3 3
1 5
10 15
20 25
6 9
5 10
30 35
Yes

No Yes

</p>