#C5190. Dynamic Set Manager

    ID: 48812 Type: Default 1000ms 256MiB

Dynamic Set Manager

Dynamic Set Manager

You are given a dynamic set of integers along with a series of queries. There are three types of queries:

  • 1 x: Add the integer x to the set.
  • 2 x: Remove the integer x from the set. It is guaranteed that x exists in the set when this query is issued.
  • 3 l r: Find the maximum integer in the set that lies in the inclusive range [l, r]. If no such integer exists, output None.

The queries are processed in the order given. For each query of type 3, print the result on a new line.

Note: The answer must be computed using efficient data management. You need to implement a dynamic set manager that supports the operations described above.

The relationship to mathematical operations is that the maximum in a range is defined as follows:

$$\max \{ x \in S \mid l \le x \le r \},$$

where \(S\) is the current set of integers.

inputFormat

The first line of input contains a single integer Q, the number of queries. The following Q lines each contain a query. A query is given in one of the following formats:

  • 1 x to add an integer x to the set.
  • 2 x to remove an integer x from the set.
  • 3 l r to find the maximum integer in the set in the inclusive range \([l, r]\).

For each query of type 3, print the result on a new line. If no integer exists in the range, print None.

outputFormat

For every query of type 3, output a single line containing the maximum integer in the specified range. If there is no integer within the range, output None.

## sample
6
1 5
1 10
1 15
3 1 10
2 5
3 1 10
10

10

</p>