#K15561. Maximizing Minimum Adjacent Difference Permutation

    ID: 24384 Type: Default 1000ms 256MiB

Maximizing Minimum Adjacent Difference Permutation

Maximizing Minimum Adjacent Difference Permutation

Given a positive integer ( n ), construct a permutation ( a_1, a_2, \dots, a_n ) of the set ( {1, 2, \dots, n} ) such that the minimum absolute difference between any two adjacent elements, i.e., ( \min_{1 \le i < n} |a_i - a_{i+1}| ), is maximized. You are required to process multiple test cases. For each test case, output a permutation that meets the criteria. It can be proven that one valid construction is to list all odd numbers in ascending order followed by all even numbers in ascending order (with a slight modification when ( n ) is odd).

inputFormat

The first line contains an integer ( T ) representing the number of test cases. Each of the following ( T ) lines contains a single integer ( n ) representing a test case.

outputFormat

For each test case, print a permutation of ( {1,2,\dots,n} ) as a sequence of space-separated integers in one line that maximizes the minimum adjacent difference.## sample

3
3
4
5
1 3 2

1 3 2 4 1 3 5 2 4

</p>