You are given an array A containing N integers. The following functions are defined for this array:
- \(f_1(l,r) = \)XOR of the first M smallest elements in the subarray from l to r, \(l \le r\) and \(r-l+1 \ge M\)
- \(f_2(l,r) = \)XOR of the first P largest elements in the subarray from l to r, \(l \le r\) and \(r-l+1 \ge P\)
- \(f_3(l,r) = f_1(l,r) \space \& \space f_2(l,r)\), \(l \le r\)
Write a program to find l and r such that \(f_3(l,r)\) is maximum. If there are several values of l and r for which \(f_3(l,r)\) is maximum, return the one having the largest length. If multiple values still exist, return the one with the smallest l.
Input format
- First line: T (number of test cases)
- First line in each test case: Three space-separated integers denoting N,M, and P respectively.
- Second line in each test case: N space-separated integers (denoting the array A)
Output format
For each test case, print three space-separated integers denoting l, r, and \(f_3(l,r)\).
Constraints
\(1 \le T \le 5\)
\(1 \le N \le 2000\)
\(1 \le M, P \le N\)
\(0 \le A[i] \le 10^9\)
In the Case 1 : since \(M=P=2\) so we require a sub-array with a length of atleast 2. \(\{3, 4\}\) is giving a maximum possible value of \(f_3(l,r)\).
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor