B - Music Player Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

高橋君は音楽プレイヤーを持っています。はじめ、音量は 0 であり、曲は停止中です。

これから、Q 回の操作を順に行います。i 回目の操作は整数 A_i によって表され、操作の内容は以下の通りです。

  • A_i = 1 のとき、音量を 1 上げる。
  • A_i = 2 のとき、現在の音量が 1 以上であれば音量を 1 下げ、0 であれば何もしない。
  • A_i = 3 のとき、曲が停止中であれば曲を再生し、曲が再生中であれば曲を停止する。

i = 1, 2, \ldots, Q に対して、以下の問題を解いてください。

  • i 回目の操作を終えた直後に音量 3 以上で音楽が再生されているか判定せよ。

制約

  • 1 \leq Q \leq 2 \times 10^5
  • A_i \in \lbrace 1, 2, 3 \rbrace
  • 入力される値はすべて整数

入力

入力は以下の形式で標準入力から与えられる。

Q
A_1
A_2
\vdots
A_Q

出力

Q 行出力せよ。i 行目には、i 回目の操作を終えた直後に音量 3 以上で音楽が再生されているならば Yes を、そうでないならば No を出力せよ。


入力例 1

10
2
1
3
1
3
1
1
3
2
2

出力例 1

No
No
No
No
No
No
No
Yes
Yes
No
  • 1 回目の操作を終えた後、音量は 0 で曲は停止中です。

  • 2 回目の操作を終えた後、音量は 1 で曲は停止中です。

  • 3 回目の操作を終えた後、音量は 1 で曲は再生中です。

  • 4 回目の操作を終えた後、音量は 2 で曲は再生中です。

  • 5 回目の操作を終えた後、音量は 2 で曲は停止中です。

  • 6 回目の操作を終えた後、音量は 3 で曲は停止中です。

  • 7 回目の操作を終えた後、音量は 4 で曲は停止中です。

  • 8 回目の操作を終えた後、音量は 4 で曲は再生中です。

  • 9 回目の操作を終えた後、音量は 3 で曲は再生中です。

  • 10 回目の操作を終えた後、音量は 2 で曲は再生中です。

Score : 200 points

Problem Statement

Takahashi has a music player. Initially, the volume is 0 and the music is stopped.

From now on, Q operations will be performed in order. The i-th operation is represented by an integer A_i, which means the following:

  • If A_i = 1, increase the volume by 1.
  • If A_i = 2, if the current volume is 1 or more, decrease it by 1; if it is 0, do nothing.
  • If A_i = 3, if the music is stopped, play it; if the music is playing, stop it.

For i = 1, 2, \ldots, Q, solve the following problem:

  • Determine whether the music is playing at volume 3 or more immediately after the i-th operation.

Constraints

  • 1 \leq Q \leq 2 \times 10^5
  • A_i \in \lbrace 1, 2, 3 \rbrace
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

Q
A_1
A_2
\vdots
A_Q

Output

Output Q lines. The i-th line should contain Yes if the music is playing at volume 3 or more immediately after the i-th operation, and No otherwise.


Sample Input 1

10
2
1
3
1
3
1
1
3
2
2

Sample Output 1

No
No
No
No
No
No
No
Yes
Yes
No
  • After the 1-st operation, the volume is 0 and the music is stopped.

  • After the 2-nd operation, the volume is 1 and the music is stopped.

  • After the 3-rd operation, the volume is 1 and the music is playing.

  • After the 4-th operation, the volume is 2 and the music is playing.

  • After the 5-th operation, the volume is 2 and the music is stopped.

  • After the 6-th operation, the volume is 3 and the music is stopped.

  • After the 7-th operation, the volume is 4 and the music is stopped.

  • After the 8-th operation, the volume is 4 and the music is playing.

  • After the 9-th operation, the volume is 3 and the music is playing.

  • After the 10-th operation, the volume is 2 and the music is playing.