XOR Queries
InterviewTime limit2sMemory limit1024 MB
Given an array with point updates, find the i-th largest value after XOR-ing every element with x, for each type 2 query.
- Level
Medium5 of 10
- Topics
- Trie, Bit manipulation
- Solved
- No attempts yet
Problem
A sequence of integers of length is given. Write a program that processes the following queries.
- : Change the value of to .
- : Print the -th largest value, counting duplicates, in the sequence .
Here, is the bitwise exclusive OR (xor) of and .
Input
The first line contains the length of the sequence .
The second line contains integers , separated by spaces.
The third line contains the number of queries .
From the fourth line on, lines follow, each containing one query. Type 2 queries appear at least once.
Output
For each type 2 query, print the result on its own line.