#K6846. Construct Modified Array
Construct Modified Array
Construct Modified Array
Given an integer \(N\), you are required to construct an array of unique positive integers according to the following rules:
- If \(N = 1\), output \(-1\) as it is impossible to construct the required array.
- If \(N\) is even, output the array \([1, 2, \dots, N]\).
- If \(N\) is odd (and greater than 1), output the array \([1, 2, \dots, N-1, N+1]\), i.e. use the consecutive integers from 1 to \(N-1\) and then append \(N+1\) as the last element.
This construction ensures that the array follows a specific pattern based on the parity of \(N\). Note that the function name is construct_even_sum_array
; however, follow the above instructions to construct the array exactly as specified.
Examples:
Input: 2 Output: 1 2</p>Input: 3 Output: 1 2 4
Input: 4 Output: 1 2 3 4
You will be given \(T\) test cases and must process each one independently.
inputFormat
The first line of the input contains a single integer \(T\), representing the number of test cases. Each of the following \(T\) lines contains one integer \(N\), which denotes the required length of the output array.
outputFormat
For each test case, print the resulting array on a new line. If a valid array exists, output the numbers separated by a single space. If it is impossible to construct the array (i.e. when \(N = 1\)), print \(-1\).
## sample3
1
2
3
-1
1 2
1 2 4
</p>