#P11160. Multiset Maintenance and Bitwise Lowbit Operations

    ID: 13224 Type: Default 1000ms 256MiB

Multiset Maintenance and Bitwise Lowbit Operations

Multiset Maintenance and Bitwise Lowbit Operations

You are given an initially empty multiset \(S\). You need to process a series of operations on \(S\):

  1. 1 x: Insert the number \(x\) into \(S\).
  2. 2 x: Delete one occurrence of the number \(x\) from \(S\). It is guaranteed that at least one \(x\) exists in \(S\) when this operation is performed. If there are multiple occurrences, delete only one.
  3. 3 x k v: For every \(y\) in \(S\) satisfying \(\operatorname{lowbit}(x \oplus y) \ge 2^k\), increase \(y\) by \(v\) modulo \(2^{32}\).
  4. 4 x: Query and output \(\max_{y \in S} \operatorname{lowbit}(x \oplus y)\). It is guaranteed that \(S\) is non-empty when this operation is performed.

Here, \(\oplus\) denotes the bitwise XOR operation. The function \(\operatorname{lowbit}(x)\) is defined as the largest power of \(2\) that divides \(x\). In this problem, we define \(\operatorname{lowbit}(0)=2^{32}\>.

inputFormat

The first line contains an integer \(n\), the number of operations.

Each of the next \(n\) lines contains an operation in one of the four formats described above.

outputFormat

For each operation of type 4, output the result on a new line.

sample

5
1 5
1 7
4 5
2 7
4 5
4294967296

4294967296

</p>