PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SRD0000124. Lena và các truy vấn (Lena and Queries)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

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 nn operations in their given order:

  • 1 a b: add a pair (a,b)(a,b). 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 jj. It is guaranteed that operation jj is an earlier type-1 operation and that its added pair has not yet been removed.
  • 3 x: among all pairs (a,b)(a,b) currently present, find the maximum value of a⋅x+ba\cdot x+b.

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 nn.
  • Each of the following nn lines describes an operation 1 a b, 2 j, or 3 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): 1≤n≤801\le n\le 80; ti∈{1,2,3}t_i\in\{1,2,3\}; −109≤a,b,x≤109-10^9\le a,b,x\le10^9; for each type-2 operation, 1≤j<i1\le j<i, operation jj added a pair that has not been removed.
  • Subtask 2 (20 points): 1≤n≤30001\le n\le 3000; ti∈{1,2,3}t_i\in\{1,2,3\}; −109≤a,b,x≤109-10^9\le a,b,x\le10^9; for each type-2 operation, 1≤j<i1\le j<i, operation jj added a pair that has not been removed.
  • Subtask 3 (30 points): 1≤n≤300001\le n\le 30000; ti∈{1,2,3}t_i\in\{1,2,3\}; −109≤a,b,x≤109-10^9\le a,b,x\le10^9; for each type-2 operation, 1≤j<i1\le j<i, operation jj added a pair that has not been removed.
  • Subtask 4 (40 points): 1≤n≤3000001\le n\le 300000; ti∈{1,2,3}t_i\in\{1,2,3\}; −109≤a,b,x≤109-10^9\le a,b,x\le10^9; for each type-2 operation, 1≤j<i1\le j<i, operation jj 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 (2,3)(2,3) gives 2⋅1+3=52\cdot1+3=5 at x=1x=1. After adding (−1,100)(-1,100), the candidate values are 55 and 9999, so the maximum is 9999. Removing the pair added at operation 44 leaves 55 again.