Type: Default 1000ms 256MiB

普通平衡树

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

这是一道模板题。

您需要写一种数据结构(可参考题目标题),来维护一些数,其中需要提供以下操作:

  1. 插入 x x 数;
  2. 删除 x x 数(若有多个相同的数,只删除一个);
  3. 查询 x x 数的排名(若有多个相同的数,输出最小的排名);
  4. 查询排名为 x x 的数;
  5. x x 的前驱(前驱定义为小于 x x ,且最大的数);
  6. x x 的后继(后继定义为大于 x x ,且最小的数)。

输入格式

第一行为 n n ,表示操作的个数,下面 n n 行每行有两个数 opt \mathrm{opt} x x opt \mathrm{opt} 表示操作的序号(1opt6 1 \leq \mathrm{opt} \leq 6 )。

输出格式

对于操作 3、4、5、6 每行输出一个数,表示对应答案。

10
1 106465
4 1
1 317721
1 460929
1 644985
1 84185
1 89851
6 81968
1 492737
5 493598
106465
84185
492737

提示

1n105,107x107 1 \leq n \leq 10 ^ 5, -10 ^ 7 \leq x \leq 10 ^ 7

模板

Not Claimed
Status
Done
Problem
7
Open Since
2025-5-30 0:00
Deadline
2025-6-7 23:59
Extension
24 hour(s)