#SRD0000124. Lena và các truy vấn (Lena and Queries)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Lena và các truy vấn (Lena and Queries)
Lena and Queries
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Initially there is an empty collection of integer pairs. Process operations in their given order:
1 a b: add a pair . Every addition is identified by the index of the operation that performed it; equal-valued pairs added at different operations can be removed independently.2 j: remove the pair that was added by operation . It is guaranteed that operation is an earlier type-1 operation and that its added pair has not yet been removed.3 x: among all pairs currently present, find the maximum value of .
If the collection is empty when a type-3 query occurs, output exactly EMPTY SET (case and space must match). A numeric answer may be negative and fits in signed 64-bit integer type.
Input
- The first line contains .
- Each of the following lines describes an operation
1 a b,2 j, or3 x.
Output
For each type-3 operation, output the maximum value on its own line; if the collection is empty, output exactly EMPTY SET. Other operations produce no output.
Subtasks
- Subtask 1 (10 points): ; ; ; for each type-2 operation, , operation added a pair that has not been removed.
- Subtask 2 (20 points): ; ; ; for each type-2 operation, , operation added a pair that has not been removed.
- Subtask 3 (30 points): ; ; ; for each type-2 operation, , operation added a pair that has not been removed.
- Subtask 4 (40 points): ; ; ; for each type-2 operation, , operation added a pair that has not been removed.
Examples
Sample 1
Input
7
3 1
1 2 3
3 1
1 -1 100
3 1
2 4
3 1
Output
EMPTY SET
5
99
5
Explanation
The first query sees an empty collection and prints EMPTY SET. Adding gives at . After adding , the candidate values are and , so the maximum is . Removing the pair added at operation leaves again.