Xor and Insert
Practice
4.4 (30 votes)
Advanced data structures
Data structures
Medium
Tries
Problem
88% Success 4165 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
At the first, you have a set $$S = {0}$$ (it contains a zero). There are three types of query:
- $$1\ x$$: Add $$x$$ to the set.
- $$2\ x$$: For each element like $$y$$ set $$y = y \oplus x$$ ($$\oplus$$ means bitwise exclusive OR, More information).
- $$3$$: Print the minimum of the set.
Input
The first line contains an integer $$q$$ ($$q \le 500\ 000$$).
In the next $$q$$ lines, queries are given.
$$x \le 10^9$$.
Output
For each query of the third type, print the answer.
Submissions
Please login to view your submissions
Similar Problems
Points:30
5 votes
Tags:
Advanced Data StructuresData StructuresMediumTriesmedium
Points:30
25 votes
Tags:
ApprovedData StructuresMediumReadyTries
Points:30
44 votes
Tags:
MediumString ManipulationTreesTries
Editorial