#K84582. Taco Array Construction
Taco Array Construction
Taco Array Construction
In this problem, you are given a positive integer (n) (with (n \ge 2)). Your task is to construct a permutation of the integers from 1 to (n) with a special property. If (n = 2) no valid permutation exists, and you must output NO
. Otherwise, if (n) is even, output a permutation that consists of the odd numbers in increasing order followed by the even numbers in increasing order; if (n) is odd, output a permutation that consists of the even numbers in increasing order followed by the odd numbers in increasing order.
For example, when (n = 4), one acceptable answer is [1, 3, 2, 4]
and when (n = 3) the answer is [2, 1, 3]
.
Note: Although the problem description mentions a condition regarding the absolute difference between consecutive elements, please follow the construction strategy described above which is guaranteed to yield the desired output format.
inputFormat
The first line of the input contains an integer (t) (the number of test cases). Each of the following (t) lines contains a single integer (n) denoting the size of the array to be constructed.
outputFormat
For each test case, if no valid permutation exists, output a single line containing NO
. Otherwise, output two lines: the first line containing YES
and the second line containing the constructed permutation ((n) space-separated integers).## sample
1
2
NO
</p>