Consider an array A with N elements. The task is to identify the shortest possible contiguous subarray where the Bitwise OR of the elements within the subarray equals the Bitwise OR of the elements outside the subarray. Additionally, determine the count of all such minimal-length subarrays that meet this condition.
Note:
Input format
Output format
For each test case, If the answer exists, print 2 integers, where the first one is the shortest possible contiguous subarray where the Bitwise OR of the elements within the subarray equals the Bitwise OR of the elements outside the subarray, & the second one is the count of all such minimal-length subarrays, in a new line, Otherwise If in the given array there exists no such subarray for which the Bitwise OR of the elements within the subarray equals the Bitwise OR of the elements, print a single integer -1, in a new line.
Constraints
1≤T≤1052≤N≤1060<A[i]≤109 ∀ i∈[1,N]The sum of all values of N over all test cases doesn't exceed 106
The first line denotes T = 1.
For test case 1, we are given:
In the given array, there are the following 4 smallest-sized subarrays with their Bitwise OR of the elements within the subarray equaling the Bitwise OR of the elements outside the subarray.
Thus, the answer is 2 4.
For test case 2, we are given:
In the given array, there exists no such subarray for which the Bitwise OR of the elements within the subarray equals the Bitwise OR of the elements outside the subarray.
Thus, the answer is -1.