Minimum Xor Pair Query - MarisaOJ: Marisa Online Judge

Minimum Xor Pair Query

Time limit: 2000 ms
Memory limit: 256 MB
For a sequence of integers initially empty, perform a series of $q$ queries of the following types: - `1 x`: Add the integer $x$ to the sequence. - `2 x`: Remove **one** occurrence of $x$ from the sequence. There is at least one $x$ in the sequence at this point. - `3`: Print the minimum XOR value between two distinct integers in the sequence. There are at least two numbers in the sequence at this point. ### Input - The first line contains an integer $q$. - The next $q$ lines each contain a query in the specified format. ### Output - Print the answer as an integer for each query of type $3$. ### Constraints - $1 \le q \le 3 \times 10^5$. - $0 \le x < 2 ^ {30}$. ### Example Input: ``` 9 1 2 1 10 3 1 3 3 2 2 3 1 10 3 ``` Output: ``` 8 1 9 0 ```