#P1630B. Range and Partition
Range and Partition
No submission language available for this problem.
Description
Given an array of integers, find a range of values (), and split into exactly () subarrays in such a way that:
- Each subarray is formed by several continuous elements of , that is, it is equal to for some and ().
- Each element from belongs to exactly one subarray.
- In each subarray the number of elements inside the range (inclusive) is strictly greater than the number of elements outside the range. An element with index is inside the range if and only if .
Print any solution that minimizes .
The input consists of multiple test cases. The first line contains a single integer () — the number of test cases. Description of the test cases follows.
The first line of each test case contains two integers and () — the length of the array and the number of subarrays required in the partition.
The second line of each test case contains integers () where is the -th element of the array.
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, print lines.
In the first line, print and — the limits of the found range.
Then print lines, the -th should contain and () — the limits of the -th subarray.
You can print the subarrays in any order.
Input
The input consists of multiple test cases. The first line contains a single integer () — the number of test cases. Description of the test cases follows.
The first line of each test case contains two integers and () — the length of the array and the number of subarrays required in the partition.
The second line of each test case contains integers () where is the -th element of the array.
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, print lines.
In the first line, print and — the limits of the found range.
Then print lines, the -th should contain and () — the limits of the -th subarray.
You can print the subarrays in any order.
Samples
Note
In the first test, there should be only one subarray, which must be equal to the whole array. There are elements inside the range and elements outside, if the chosen range is , there will be element inside () and element outside (), and the answer will be invalid.
In the second test, it is possible to choose the range , and split the array in subarrays and , in subarray there are elements inside the range ( and ) and element outside (), in subarray there is only element (), and it is inside the range.
In the third test, it is possible to choose the range , and split the array in subarrays , and , in the subarray there are elements inside the range and element outside, in the subarray there are elements inside and element outside and in the subarray there are elements inside and element outside.