[Solution] Split AND Sum CodeChef Solution | CodeChef Problem Solution 2022
You are given an array . You want to split it into several subarrays so that the following condition holds:
- Calculate the sum of elements in each subarray. Then, the
AND
of all these sums is nonzero, whereAND
denotes the bitwise AND operation.
Determine if it's possible. If it's possible, find one such split. You don't
have to minimize the number of subarrays.
Input Format
- The first line of the input contains a single integer the number of test cases. The description of the test cases follows.
- The first line of each test case contains a single integer the length of the array.
- The second line of each test case contains space-separated integers .
Output Format
For each test case, if it's not possible to split the array so that the condition from the statement holds, output NO
.
Otherwise, output YES
. In the next line, output () the number of subarrays you are splitting into.
In the -th of the next lines, output two integers (), where denotes the -th subarray.
Each number from to has to appear in exactly one of the segments .
You can output each letter in either uppercase or lowercase. You can output any solution. You don't have to minimize .
Constraints
- Sum of over all test cases doesn't exceed
No comments:
Post a Comment