XOR Equal codechef solution
You are given an arrayconsisting of integers and an integer . Your goal is to have as many equal integers as possible in the array. To achieve this goal, you can do the following operation:
- Choose an index bitwise xor operation. and set , where denotes the
Find the maximum number of equal integers you can have in the final array and the minimum number of operations to obtain these many equal integers.
- The first line of the input contains a single integer denoting the number of test cases. The description of test cases follows.
- Each test case contains two lines of input.
- The first line of each test case contains two space-separated integers .
- The second line of each test case contains space-separated integers .
For each test case, print a single line containing two space-separated integers – first, the maximum number of equal integers in the final array and second, the minimum number of operations to achieve these many equal integers.
- The sum of over all test cases does not exceed .
Subtask #1 (100 points): Original constraints
Sample Input 1
3 3 2 1 2 3 5 100 1 2 3 4 5 4 1 2 2 6 6
Sample Output 1
2 1 1 0 2 0
Test case: One way to obtain equal integers is to set . So the array becomes . There is no way to obtain equal integers in the final array.
Test case: There is no way to obtain more than one equal integer.
Also read : Airline Restrictions codechef solution
Also read :Travel Pass codechef solution
Also read : Shuffling Parities codechef solution
Also read : Friend Groups In A Line solution codechef