Minimum XOR
Practice
3.3 (10 votes)
Trie
Advanced data structures
Data structures
Problem
30% Success 1261 Attempts 30 Points 3s Time Limit 256MB Memory 1024 KB Max Code
You are given \(q\) queries of two types:
- \(1\ X\): Append value \(X\) into an array.
- \(2\ X\ K\): You are required to print the \(K^{th}\) minimum XOR of \(X\) with the current array.
You have to make a new array whose \(i^{th}\) element is current_array[i]\(^X\). Then sort it and print the \(K^{th}\) element.
Input format
- The first line contains \(q\ (1\le q \le 100000)\).
- Next \(q\) lines contain the types of queries. (1 or 2)
- If type is 1, then it contains \(X\ (1\le X\le 10e18)\).
- If type is 2, then it contains \(X\ (1\le X\le 10e18)\) and \(K\ (K\le current\ array\ size)\).
Output format
Print the number in the second type of query.
Submissions
Please login to view your submissions
Similar Problems
Points:30
30 votes
Tags:
Advanced Data StructuresData StructuresMediumTries
Points:30
10 votes
Tags:
ApprovedData StructuresMediumOpenTreesTries
Points:30
17 votes
Tags:
Data StructuresMediumTries
Editorial