K-th Smallest XOR Value
Consider all distinct XOR values obtainable from subsets of the array (the empty subset gives 0). Print the K-th smallest distinct value, or −1 if fewer than K exist.
Input: the first line has N and K; the second line has N non-negative integers.
Output: the K-th smallest achievable XOR, or −1.
Constraints:
- 1 ≤ N ≤ 105
- 0 ≤ ai < 230
Sample Tests
Input 1
3 3 1 2 3
Output 1
2
Input 2
2 4 1 2
Output 2
3
Discussion (opens after you solve — no spoilers before)
No comments yet.