PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000152. Tập con bit (Subset of Bits)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tập con bit (Subset of Bits)
Subset of Bits
Source: VNOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Initially you have an empty multiset of nonnegative integers. Process operations; duplicate copies are allowed and counted individually:
add s: insert one copy of .del s: remove exactly one copy of , guaranteed to exist at the time of removal.cnt s: count the current copies of values satisfying bitwise .
Equivalently, every set bit of must also be set in .
Input
- The first line contains positive integer .
- Each of the next lines contains an operation keyword
add,del, orcnt, followed by integer .
Output
For each cnt query print the number of currently stored copies satisfying . Insertions and deletions have no output.
Subtasks
- Subtask 1 (20 points): ; ; every
del sremoves an existing copy. - Subtask 2 (30 points): ; ; every
del sremoves an existing copy. - Subtask 3 (50 points): ; ; every
del sremoves an existing copy.
Examples
Example 1
Input
7
add 11
cnt 15
add 4
add 0
cnt 6
del 4
cnt 15
Output
1
2
2
Explanation
After adding , cnt 15 counts it since : answer . After inserting and , cnt 6 counts and but not , hence . Deleting leaves and , both submasks of , hence $2.