#P7502. 「HMOI R1」不知道是啥的垃圾题

「HMOI R1」不知道是啥的垃圾题

Description

You need to maintain a multiset that supports three operations:

  1. Insert a pair of non-negative integers.
  2. Delete a pair of non-negative integers. It is guaranteed that this pair is already in the set.
  3. Given a pair of non-negative integers (x,y)(x,y), ask how many pairs (a,b)(a,b) in the set satisfy xxora>yxorbx\operatorname{xor}a>y\operatorname{xor}b, where xor\operatorname{xor} denotes the bitwise XOR operation.

In this problem, all “pairs” refer to ordered pairs.

Input Format

The first line contains a non-negative integer MM, representing the number of operations.

The next MM lines each contain one operation in the following format:

  • 1 x y means inserting the pair (x,y)(x,y).
  • 2 x y means deleting the pair (x,y)(x,y). It is guaranteed that (x,y)(x,y) appears in the multiset at least once at this moment.
  • 3 x y means querying the pair (x,y)(x,y).

Output Format

Output MM lines. For each query, output one line with a non-negative integer, representing the answer to the query.

6
3 1 2
1 3 2
1 4 5
3 6 2
2 3 2
3 6 2

0
1
0

Hint

For the sample, during the first query there are no pairs in the set, so the answer is 00.

During the second query, the set is {(3,2),(4,5)}\{(3,2),(4,5)\}. We have 6xor3=5>0=2xor26\operatorname{xor}3=5>0=2\operatorname{xor}2, and 6xor4=2<7=2xor56\operatorname{xor}4=2<7=2\operatorname{xor}5. Therefore, the only pair that satisfies the condition is (3,2)(3,2), so the answer is 11.

During the third query, the set is {(4,5)}\{(4,5)\}. There is no pair that satisfies the condition, so the answer is 00.


For all testdata:

  • 0M2×1050 \le M \le 2 \times 10^5.
  • 0x,y10180 \le x, y \le 10^{18}.

This problem uses bundled tests.

No. Constraints Score
11 M2000M \le 2000 1010
22 x,y<8x, y < 8 2020
33 x,yMx, y \le M 3030
44 No further constraints 4040

  • Idea: FZzzz
  • Solution: FZzzz
  • Code: FZzzz
  • Data: FZzzz

Translated by ChatGPT 5