[Solved] XOR Equal codechef solution

XOR Equal codechef solution

You are given an array AA consisting of NN integers and an integer XX. 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 ii (1iN)(1≤i≤N) and set Ai=AiXAi=Ai⊕X, where  denotes the bitwise xor operation.

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.

Input Format

• The first line of the input contains a single integer TT denoting the number of test cases. The description of TT test cases follows.
• Each test case contains two lines of input.
• The first line of each test case contains two space-separated integers N,XN,X.
• The second line of each test case contains NN space-separated integers A1,A2,,ANA1,A2,…,AN.

Output Format

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.

Constraints

• 1T1041≤T≤104
• 1N1051≤N≤105
• 0X1090≤X≤109
• 0Ai1090≤Ai≤109
• The sum of NN over all test cases does not exceed 51055⋅105.

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


Explanation

Test case 11: One way to obtain 22 equal integers is to set A1=A12A1=A1⊕2 =12=3=1⊕2=3. So the array becomes [3,2,3][3,2,3]. There is no way to obtain 33 equal integers in the final array.

Test case 22: 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