#K33952. Non-overlapping Planting Sections
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 . You are also given a list of query intervals . For each query interval, determine whether it is free of any overlap with the pre-defined sections. Two intervals and 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 and , where is the number of pre-defined sections and is the number of queries. The next lines each contain two integers and representing the start and end points of the sections. This is followed by lines, each containing two integers and 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>