Integers

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

요약
a·2^b를 더하는 갱신과 k번째 이진 자리를 묻는 질의를 처리한다.
난이도

어려움10점 중 8점

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

문제

There is an integer xx, initially zero.

There are nn operations. Each operation is one of the following types:

  • 1 a b: Add a⋅2ba \cdot 2^b to xx where aa is an integer (that can be negative) and bb is a non-negative integer.
  • 2 k: Write xx in binary, and compute the value of the digit corresponding to a weight of 2k2^k.

It is guaranteed that x≥0x \geq 0 at any time.

입력

The first line of the input consists of four integers, n,t_1,t_2,t_3n,t\_1,t\_2,t\_3.

In the following nn lines, each line describes an operation.

Two adjacent elements in a line are separated by exactly one space.

출력

For each type 2 k query, output a line with an integer (0 or 1) denoting the answer. There shall be no output for each operation of 1 a b.

제한

For all test cases, 1≤t_1≤3,1≤t_2≤4,1≤t_3≤21 \leq t\_1 \leq 3, 1 \leq t\_2 \leq 4, 1 \leq t\_3 \leq 2.

Explanation of t_1t\_1

  • If a test case has t_1=1t\_1 = 1, then a=1a = 1.
  • If a test case has t_1=2t\_1 = 2, then ∣a∣=1|a| = 1.
  • If a test case has t_1=3t\_1 = 3, then ∣a∣≤109|a| \leq 10^9.

Explanation of t_2t\_2

  • If a test case has t_2=1t\_2 = 1, then 0≤b,k≤300 \leq b,k \leq 30.
  • If a test case has t_2=2t\_2 = 2, then 0≤b,k≤1000 \leq b,k \leq 100.
  • If a test case has t_2=3t\_2 = 3, then 0≤b,k≤n0 \leq b,k \leq n.
  • If a test case has t_2=4t\_2 = 4, then 0≤b,k≤30n0 \leq b,k \leq 30n.

Explanation of t_3t\_3

  • If t_3=1t\_3 = 1, then all queries are after updates.
  • If t_3=2t\_3 = 2, then there are no additional constraints.

예제1

  1. 예제 1

    입력
    10 3 1 2
    1 100 0
    1 2333 0
    1 -233 0
    2 5
    2 7
    2 15
    1 5 15
    2 15
    1 -1 12
    2 15
    
    예상 출력
    0
    1
    0
    1
    0