Subarray permutations solution codechef
A permutation of lengthis an array of integers such that every integer from to (inclusive) appears in it exactly once. For example, is a permutation of length .
A subsegment of an array] is called good if the subsegment is a permutation of length . For example, the array contains good subsegments: .
You are given two integers
-1 if no such permutation exists.
Input Format Subarray permutations solution codechef
- The first line contains an integer , denoting the number of test cases. The test cases then follow:
- The first and only line of each test case contains two space-separated integers .
For each test case, output a single line containing the answer:
- If no permutation satisfies the given conditions, print
- Otherwise, print space-separated integers , denoting the elements of the permutation. If there are multiple answers, you can output any of them.
Constraints Subarray permutations solution codechef
- Sum of over all test cases does not exceed .
- Subtask 1 (100 points): Original constraints
Sample Input 1
4 1 1 3 2 4 1 5 3
Sample Output 1 Subarray permutations solution codechef
1 1 3 2 -1 5 3 1 4 2
Test case: The only permutation of length is , which contains one good subsegment .
Test case: The permutation contains good subsegments: , .
Test case: There is no way to construct a permutation of length which contains one good subsegment.
Test case: The permutation contains good subsegments: . There are other permutations of length having good subsegments.