XOR Sequence
Time limit2sMemory limit512 MB
Choose B in [0, N-1] to XOR every element of A, then find the maximum possible count of index pairs i < j with C_i < C_j.
- Level
Hard8 of 10
- Topics
- Divide and conquer, Bit manipulation, Sorting, Recursion
- Solved
- No attempts yet
Problem
You are given an integer and a sequence of length . is a power of two, and every element of is an integer between and .
You may pick one integer between and and build a new sequence . For every , set , where is bitwise exclusive or (XOR).
Then count the pairs with and in .
Write a program that finds the largest possible number of such pairs over every choice of .
Input
The first line contains . (, is a power of two)
The second line contains the size of the sequence . ()
The third line contains separated by spaces. ()
Output
Print the largest possible number of pairs with and .
Hint
For and , choosing gives . That sequence has 8 pairs with and .