CODEIT02 - PICK UP DROP ESCAPE

no tags 

PICK UP DROP ESCAPE

You are given with an array of n numbers. You must pick K elements from the array such that XOR of all the chosen elements is maximum.

http://en.wikipedia.org/wiki/Bitwise_operation#XOR

 

Input Specification:

The first line consists of an integer t representing the number of test cases. For each test case the first line consists of two numbers n and K denoting the number of elements in the array and the number of elements to be chosen respectively. Then in the next n lines, the elements in the array are given.

Output Specification:

For each test case print a line containing one integer denoting the maximum XOR value of the chosen K elements.

 

Input Constraints:

1<=t<=100

1<=n<=20

1<=k<=n

1<=element value<=10000

 

Sample Input:

2

 

5 3

1

2

3

4

5

 

5 3

3

4

5

7

4

Sample Output:

7

7


hide comments
scolar_fuad: 2019-11-07 18:44:57

Can I apply bitmask approach here >?

pshiphon: 2019-07-11 20:56:13

[spoiler removed]

Last edit: 2019-11-04 16:29:10
Aman Parashar: 2015-06-04 08:10:24

Best Solution :)

Last edit: 2015-06-04 08:57:57
Rishabh Joshi: 2015-05-26 20:33:33

did this just after XMAX. Didnt interpret the question clearly. got 4-5 WA.
Nice learning though.


Added by:cegprakash
Date:2012-01-09
Time limit:0.107s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64