[Solution] Subarray Removal CodeChef Solution
Problem
Chef has a binary array of length . In one operation, Chef does the following:
1. Select any and such that 2. Add to his score (Here, denotes the bitwise XOR operation)3. Remove the subarray from
Determine the maximum score Chef can get after performing the above operation any number of times.
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 an integer — the size of the array .
- The second line of each test case contains space-separated integers denoting the array .
Output Format
For each test case, output the maximum score Chef can get.
Explanation:
Test Case 1: We can perform the following moves:
- . Select and and remove subarray . becomes .
- . Select and and remove subarray . becomes .
👇👇👇👇👇
Total score
Test Case 2: We can perform the following move:
- . Select and and remove subarray . becomes .
Total score
No comments:
Post a Comment