QOJ.ac

QOJ

时间限制: 2 s 内存限制: 1024 MB 总分: 100 可 Hack ✓

#18454. 集合与序列与查询

统计

Takina 和 Chisato 正在用一个正整数集合玩游戏。 这个游戏的目标是利用集合中的数字构造连续递增序列。 连续递增序列定义为长度为 $k$($k \ge 1$)的序列 $a_1, a_2, \dots, a_k$,满足对于所有 $1 \le i \le k - 1$,都有 $a_{i+1} = a_i + 1$。

游戏开始时集合为空,共进行 $Q$ 次操作。在每一轮中,Takina 可以向集合中插入一个新整数,或者从集合中删除一个整数。 每当集合发生变化时,Chisato 都需要计算利用集合中的数字可以构成多少个不同的连续递增序列。 你的任务是帮助 Chisato。

输入格式

第一行包含操作次数 $Q$。 接下来的 $Q$ 行,每行包含两个整数,描述 Takina 的操作。每行格式如下:

  • $1 \ x$:将 $x$ 插入集合。保证 $x$ 此前不在集合中。
  • $2 \ x$:从集合中删除 $x$。保证 $x$ 此前在集合中。

输出格式

输出 $Q$ 个整数,每行一个,表示每次 Takina 操作后集合中连续递增序列的数量。

数据范围

  • $1 \le Q \le 300\,000$
  • $1 \le x \le 10^9$

样例

样例输入 1

3
1 1
1 2
2 1

样例输出 1

1
3
1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.