#abc308g. G - Minimum Xor Pair Query
G - Minimum Xor Pair Query
Score : points
问题描述
在一块黑板上,你可以写入整数。初始时,黑板上没有写任何整数。给定 个查询,按顺序处理它们。
查询有以下三种类型:
-
1 x
:在黑板上写入一个整数。 -
2 x
:从黑板上擦除一个整数。在执行此查询时,保证至少有一个已经被写在了黑板上。 -
3
:打印黑板上所写两个整数之间可能的最小按位异或值。在处理此查询时,保证至少有两个整数被写在了黑板上。
什么是按位异或?非负整数 和 的按位异或(bitwise XOR),记作 ,定义如下:
- 当 转换为二进制表示时,第 位()为 当且仅当 和 在相应位置上的 位只有一个为 ,否则为 。
例如,(以二进制表示:)。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There is a blackboard on which you can write integers. Initially, no integer is written on the blackboard. Given queries, process them in order.
The query is of one of the following three kinds:
-
1 x
: write an on the blackboard. -
2 x
: erase an from the blackboard. At the point this query is given, it is guaranteed that at least one is written on the blackboard. -
3
: print the minimum possible bitwise XOR of two of the integers written on the blackboard. At the point this query is processed, it is guaranteed that at least two integers are written on the blackboard.
What is bitwise XOR? The bitwise XOR of non-negative integers and , , is defined as follows.
- When is written in binary, the s place () is if exactly one of the s places of and is , and otherwise.
For instance, (in binary: ).
Constraints
- When a query is given, at least one is written on the blackboard.
- When a query is given, at least two integers are written on the blackboard.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
In the -th query, , the kind of query, (one of , , or ), is first given. If or , an integer is additionally given.
In other words, each query is in one of the following three formats.
Output
Print lines, where is the number of queries such that .
The -th line should contain the answer to the -th such query.
Sample Input 1
9
1 2
1 10
3
1 3
3
2 2
3
1 10
3
Sample Output 1
8
1
9
0
After processing the -st query, a is written on the blackboard.
After processing the -nd query, a and a are written on the blackboard.
When processing the -rd query, the minimum possible bitwise XOR of two of the integers written on the backboard is .
After processing the -th query, a , a , and a are written on the blackboard.
When processing the -th query, the minimum possible bitwise XOR of two of the integers written on the backboard is .
After processing the -th query, a and a are written on the blackboard.
When processing the -th query, the minimum possible bitwise XOR of two of the integers written on the backboard is .
After processing the -th query, a and two s are written on the blackboard.
When processing the -th query, the minimum possible bitwise XOR of two of the integers written on the backboard is .
update @ 2024/3/10 08:45:14