Set and Queries
Time limit4sMemory limit512 MB
After each insertion or deletion in a set of up to 500,000 integers, report the maximum XOR achievable by any subset of the current set.
- Level
Hard8 of 10
- Topics
- Bit manipulation, Math, Greedy, Divide and conquer
- Solved
- No attempts yet
Problem
You must perform the following queries on a set .
x: add to the set .-x: remove from the set .
After each query, find the subset of whose XOR of all elements is the largest.
Input
The first line gives the number of queries (). The following lines give one query each. Every number added to the set is a positive integer less than or equal to .
The input never contains a query that adds a number already in the set or a query that removes a number not in the set.
Output
After each query, print the XOR of all elements of . If the size of the set is after a query, print .