아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Set and Sequence and Query

시간 제한2초메모리 제한1024 MB

요약
1e9 범위의 정수 집합에 삽입과 삭제가 Q번 일어날 때, 매번 연속한 값들의 구간이 집합에 몇 개 있는지를 출력한다.
난이도

보통10점 중 7점

유형
해시맵, 구현, 시뮬레이션, 수학
정답자
아직 제출이 없습니다

문제

Takina and Chisato are playing a game with a set of positive integers.

This game is about making continuous increasing sequences using the numbers from the set.

A continuous increasing sequence is defined as a sequence a_1,a_2,…,a_ka\_1,a\_2,\dots ,a\_k of positive length kk, satisfying a_i+1=a_i+1a\_{i+1}=a\_i+1 for all 1≤i≤k−11\leq i\leq k-1.

The game begins with an empty set and consists of QQ turns. In each turn, Takina can either insert a new integer into the set or delete an integer from the set.

Every time a change is made to the set, Chisato has to count how many different continuous increasing sequences can be made using the numbers from the set.

Your task is to help Chisato.

입력

The first line contains the number of turns, QQ.

The following QQ lines contain two integers, describing Takina’s move. Each line has one of the following forms:

  • 1 xx : Insert xx into the set. It is guaranteed that xx was not in the set.
  • 2 xx : Delete xx from the set. It is guaranteed that xx was in the set.

출력

Output QQ integers separated by newlines, the number of continuous increasing sequences in the set after each Takina’s move.

제한

  • 1≤Q≤300,0001\leq Q\leq 300\\, 000
  • 1≤x≤1091\leq x\leq 10^9

예제1

  1. 예제 1

    입력
    3
    1 1
    1 2
    2 1
    
    예상 출력
    1
    3
    1