#P12082. Interval Cover Union Queries

    ID: 14188 Type: Default 1000ms 256MiB

Interval Cover Union Queries

Interval Cover Union Queries

You are given two integers \(n\) and \(m\). Consider a multiset (allowing duplicates) of intervals on the number line over the range \([1, n)\) which is initially empty. You need to support \(m\) operations of the following three types:

  • Operation 1: Insert an interval \([l, r)\) into the multiset.
  • Operation 2: Delete the interval that was inserted in the \(t\)-th insertion operation.
  • Operation 3: Given an interval \([l, r)\), determine whether there exists a subset of intervals from the current multiset whose union is exactly \([l, r)\). Note that for the union to be exactly \([l, r)\), each chosen interval must lie completely within \([l, r)\) (i.e. an interval \([a, b)\) can only be chosen if \(l \le a\) and \(b \le r\)).

Note: The union of an empty set of intervals is defined as the empty set. Therefore, a query with \(l = r\) should return "YES".

Input and Output: See the input and output descriptions below.

inputFormat

The first line contains two integers \(n\) and \(m\) (\(1 \le n \le 10^9,\ 1 \le m \le 10^5\)). Each of the following \(m\) lines describes an operation in one of the formats below:

  • For an insertion operation: 1 l r where \(1 \le l < r \le n\).
  • For a deletion operation: 2 t where \(t\) is the 1-based index of an insertion operation that has not been deleted already.
  • For a query operation: 3 l r with \(1 \le l \le r \le n\). (Recall that if \(l = r\), the queried interval is empty.)

outputFormat

For each query operation, output a single line containing either YES if there exists a subset of intervals whose union is exactly \([l, r)\), or NO otherwise.

sample

10 5
1 1 4
1 3 6
3 1 6
2 1
3 1 6
YES

NO

</p>