[Solution] Adjacent Xors CodeChef Solution
Problem
JJ has an array of length and an integer . JJ can perform the following operation at most once:
- Select a subsequence of and add to all the elements of that subsequence.
For example, if and , we can select the subsequence and add to all the elements. Now the array becomes .
JJ wants to maximize the value of . Can you help him to do so?
Here, denotes the bitwise XOR operation.
Input Format
- The first line contains a single integer — the number of test cases. Then the test cases follow.
👇👇👇👇👇
- The first line of each test case contains two space-separated integers and — the size of the array and the parameter mentioned in the statement.
- The second line of each test case contains space-separated integers denoting the array .
Output Format
For each test case, output the maximum value of which can be obtained after applying the given operation at most once.
Explanation:
Test case : It is optimal to not perform the given operation. So the answer will equal .
Test case : It is optimal to add to the and the element. So will become and the answer will be .
No comments:
Post a Comment