Codeforces Round 367 (Div. 2)
D
Vasiliy's Multiset
Codeforces
1800
原题
← CE →
翻译中…

Author has gone out of the stories about Vasiliy, so here is just a formal task description.

翻译中…

You are given $*q*$ queries and a multiset $*A*$, initially containing only integer $0$. There are three types of queries:

翻译中…
  1. "+ x" — add integer $*x*$ to multiset $*A*$.
  2. "- x" — erase one occurrence of integer $*x*$ from multiset $*A*$. It's guaranteed that at least one $*x*$ is present in the multiset $*A*$ before this query.
  3. "? x" — you are given integer $*x*$ and need to compute the value image, i.e. the maximum value of bitwise exclusive OR (also know as XOR) of integer $*x*$ and some integer $*y*$ from the multiset $*A*$.
翻译中…

Multiset is a set, where equal elements are allowed.

翻译中…

Input

翻译中…

The first line of the input contains a single integer $*q*$ ($1 ≤ *q* ≤ 200 000$) — the number of queries Vasiliy has to perform.

翻译中…

Each of the following $*q*$ lines of the input contains one of three characters '+', '-' or '?' and an integer $*x*_{*i*}$ ($1 ≤ *x*_{*i*} ≤ 10^{9}$). It's guaranteed that there is at least one query of the third type.

翻译中…

Note, that the integer $0$ will always be present in the set $*A*$.

翻译中…

Output

翻译中…

For each query of the type '?' print one integer — the maximum value of bitwise exclusive OR (XOR) of integer $*x*_{*i*}$ and some integer from the multiset $*A*$.

翻译中…

Note

翻译中…

After first five operations multiset $*A*$ contains integers $0$, $8$, $9$, $11$, $6$ and $1$.

翻译中…

The answer for the sixth query is integer image — maximum among integers image, image, image, image and image.

翻译中…

样例

Input #1
10
+ 8
+ 9
+ 11
+ 6
+ 1
? 3
- 8
? 3
? 8
? 11
Output #1
11
10
14
13
InputCopy OutputCopy
题目信息
题号
706D
时间限制
4 s
内存限制
256 MB
标签
二分
位运算
数据结构
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。