Home Page > > Details

Help With data Course,Help With Python,c++ Programming

BBST
Description
You are required to maintain a multiset , which supports the following operations:
1. Insert a number to ;
2. Erase a number equal to from if exists;
3. Find the order of in , i.e., ;
4. Find the -th smallest number in ;
5. Find the precursor of a number in , i.e., if exists;
6. Find the successor of a number in , i.e., if exists.
Input
The first line of the contains an integer , indicating the number of operations followed.
In the next lines, each line contains two integers and , representing an operation, where
stands for the type of the operation.
Output
For each type 3, 4, 5, 6 operation, output a number in one line, representing the answer.
Sample
Sample 1 Input
10
1 106465
4 1
1 317721
1 460929
1 644985
1 84185
1 89851
6 81968
1 492737
5 493598
Sample 1 output
106465
84185
492737
S
x S
x S
x S 1 + ∑v∈S
[v < x]
x S
x S {v}
v∈S,vmax
x S {v}
v∈S,v>x
min
n
n opt x opt
Constraints
.
It is guaranteed that the precursor or successor exists for each type or operation.
1 ≤ n ≤ 10
5
, 1 ≤ opt ≤ 6, −10
7 ≤ x ≤ 10
7
5 6

Contact Us - Email:99515681@qq.com    WeChat:codinghelp
Programming Assignment Help!