8840: [yosupo] Data Structure - Set Xor-Min
[Creator : ]
Description
Let $S$ be an empty integer set.
Process the following $Q$ queries :
- 0 x : insert $x$ into $S$ if it is not in $S$
- 1 x : remove $x$ from $S$ if it is in $S$
- 2 x : find $\min_{i \in S}(i \oplus x)$ where $\oplus$ denotes bitwise-xor.
Process the following $Q$ queries :
- 0 x : insert $x$ into $S$ if it is not in $S$
- 1 x : remove $x$ from $S$ if it is in $S$
- 2 x : find $\min_{i \in S}(i \oplus x)$ where $\oplus$ denotes bitwise-xor.
Input
$Q$
$\mathrm{Query}_0$
$\mathrm{Query}_1$
$\mathrm{Query}_2$
$\hspace{15pt} \vdots$
$\mathrm{Query}_{Q - 1}$
$\mathrm{Query}_0$
$\mathrm{Query}_1$
$\mathrm{Query}_2$
$\hspace{15pt} \vdots$
$\mathrm{Query}_{Q - 1}$
Constraints
$1 \leq Q \leq 500000$
$0 \le x \lt 2^{30}$
$S$ is not empty when processing queries of type 2 x.
$0 \le x \lt 2^{30}$
$S$ is not empty when processing queries of type 2 x.
Sample 1 Input
6
0 6
0 7
2 5
1 7
1 10
2 7
Sample 1 Output
2
1