Powers of Two

면접 대비

시간 제한1초메모리 제한2048 MB

요약
N = 0에서 시작해 2^x를 더하거나 빼는 질의를 Q번 처리하면서, 각 질의 후 N이 0이 되는지 판정한다.
난이도

보통10점 중 6점

유형
비트 연산, 구현, 수학, 해시맵
정답자
아직 제출이 없습니다

문제

Adrian has learned addition and subtraction from Morgan and is now ready to learn a new concept, the powers of two. Powers of two are integers in the form of 2x2^x, where x≥0x ≥ 0. Some examples of powers of two are 1,2,4,8,…1, 2, 4, 8, \dots.

To ensure Adrian understands this new concept, Morgan prepares a challenge for him. At first, Adrian is given an integer N=0N = 0. Then, Morgan will give him QQ queries. Each query can be one of the following types:

  • + xx, which will add the value of NN by 2x2^x, or
  • - xx, which will subtract the value of NN by 2x2^x.

Adrian is instructed to clap his hands whenever NN becomes 00 after each query.

Adrian finds this challenge is very hard to follow. He asks you whether he should clap or not after each query.

입력

Input begins with an integer QQ (1≤Q≤200,0001 ≤ Q ≤ 200\\, 000) representing the number of queries. Each of the next QQ lines contains a character and an integer TT xx (T ∈ \\{+, -\\}; 0≤x≤200,0000 ≤ x ≤ 200\\, 000) representing the query.

출력

After each query, output YES in a single line if the value of NN becomes 00, or output NO otherwise.

예제2

  1. 예제 1

    입력
    6
    + 3
    + 3
    - 4
    - 6
    + 7
    - 6
    
    예상 출력
    NO
    NO
    YES
    NO
    NO
    YES
    
  2. 예제 2

    입력
    13
    + 13324
    + 5773
    - 5772
    + 13324
    + 0
    - 5772
    - 13325
    - 0
    + 0
    + 0
    - 200000
    - 1
    + 200000
    
    예상 출력
    NO
    NO
    NO
    NO
    NO
    NO
    NO
    YES
    NO
    NO
    NO
    NO
    YES