QOJ.ac

QOJ

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

#18454. Set and Sequence and Query

统计

たきなと千束は、正の整数の集合を使ったゲームをしています。 このゲームは、集合内の数字を使って連続する増加列を作るというものです。 連続する増加列とは、長さ $k$ ($k \ge 1$) の数列 $a_1, a_2, \dots, a_k$ であり、すべての $1 \le i \le k - 1$ に対して $a_{i+1} = a_i + 1$ を満たすものと定義されます。

ゲームは空の集合から始まり、$Q$ ターンの間行われます。各ターンで、たきなは新しい整数を集合に追加するか、集合から整数を削除します。 集合が変更されるたびに、千束は集合内の数字を使って作ることができる連続する増加列がいくつあるかを数えなければなりません。 あなたの仕事は、千束を助けることです。

入力

最初の行には、ターンの数 $Q$ が含まれます。 続く $Q$ 行には、たきなの操作を表す2つの整数が含まれます。各行は以下のいずれかの形式です。

  • $1 \ x$ : $x$ を集合に追加する。$x$ は集合に含まれていなかったことが保証されます。
  • $2 \ x$ : $x$ を集合から削除する。$x$ は集合に含まれていたことが保証されます。

出力

たきなの各操作の後、集合内に存在する連続する増加列の数を、改行区切りで $Q$ 個の整数として出力してください。

制約

  • $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.