TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

You have a list of integers, initially the list is empty.

You have to process Q operations of three kinds:

  1. add s: Add integer s to your list, note that an integer can exist more than one time in the list
  2. del s: Delete one copy of integer s from the list, it's guaranteed that at least one copy of s will exist in the list.
  3. cnt s: Count how many integers a are there in the list such that a AND s = a , where AND is bitwise AND operator

Input Format

The first line contains an integer T indicating the total number of test cases. Each test case begins with an integer Q. Each of the following Q lines contains an operation type string T and an integer s.

Constraints

  • T ≤ 16
  • 1 ≤ Q ≤ 200000
  • 0 ≤ s < 216
  • Output Format

    For each cnt s operation, output the answer in a new line.

    Sample Input 1

    1
    7
    add 11
    cnt 15
    add 4
    add 0
    cnt 6
    del 4
    cnt 15

    Sample Output 1

    1
    2
    2

    Hints

    For first line, we have 15 AND 11 = 11 so the answer is 1

    For second line, 6 AND 0 = 0 and 6 AND 4 = 4 so the answer is 2

    For third line, 4 has been deleted and we have 15 AND 11 = 11 and 15 AND 0 = 0 so the answer is 2

    Problem Source

    Migrated from old NTUJ.

    CounterCode 2015

    Subtasks

    No. Testdata Range Score

    Testdata and Limits

    No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
    0 3000 65536 131072