#P11536. Benson's Curtain Show
Benson's Curtain Show
Benson's Curtain Show
Rabbit Benson is about to organize a performance on a plane! Benson has \(n\) stages labeled from 1 to \(n\), and \(m\) curtains labeled from 1 to \(m\). When the \(i\)-th curtain is lowered, it covers all stages in the interval \([l_i, r_i]\).
Benson will hold \(q\) performances, with the \(j\)-th performance requiring the use of stages in the interval \([s_j, e_j]\). For each performance, Benson wants to know whether it is possible to choose a subset of curtains such that the union of their covered intervals is exactly \([s_j, e_j]\).
Formally: Given \(m\) intervals \([l_i, r_i]\), and for each query an interval \([s_j, e_j]\), determine whether there exists a selection of intervals whose union is exactly \([s_j, e_j]\).
Note: An interval \([a, b]\) is said to exactly cover the required stages if:
[ \bigcup_{\text{selected } i} [l_i, r_i] = [s_j, e_j] ]
Also, if \(s_j = e_j\), then a valid selection must include at least one curtain that covers exactly that single stage (i.e. an interval \([s_j, s_j]\)).
inputFormat
The first line contains three integers \(n\), \(m\), and \(q\) \((1 \leq n \leq \text{?},\ 1 \leq m,q \leq \text{?})\) representing the number of stages, curtains, and performances, respectively.
The next \(m\) lines each contain two integers \(l_i\) and \(r_i\) (\(1 \leq l_i \leq r_i \leq n\)), describing the interval covered by the \(i\)-th curtain.
The following \(q\) lines each contain two integers \(s_j\) and \(e_j\) (\(1 \leq s_j \leq e_j \leq n\)), representing the required contiguous stage interval for the \(j\)-th performance.
outputFormat
For each query, output a single line containing Yes
if it is possible to choose some curtains such that their union is exactly the interval \([s_j, e_j]\); otherwise, output No
.
sample
10 3 3
1 5
4 8
2 2
1 5
1 8
2 2
Yes
Yes
Yes
</p>