Different Median
Solution Coming Soon .................... Check back in few minutes
Problem
Chef is given an integer . Chef wants to construct a permutation of that satisfies the following condition:
- Let denote the prefix of of length , i.e, . Then, for every , it must hold that
Help Chef find such a permutation . If multiple answers exist, you may print any of them.
Note: The median of an array is defined as follows:
- Let be an (-indexed) array of length . Let be the array obtained by sorting . Then is defined to be . For example, , and
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- The first and only line of each test case contains a single integer .
Output Format
For each test case, output the required permutation. If multiple answers are possible, you may print any of them.
Constraints
- The sum of over all test cases won't exceed .
Sample 1:
Input
Output
2 2 3
2 1 2 1 3
Explanation:
Test case : The prefixes of the given permutation are and , with medians and respectively.
Test case : The prefixes of the given permutation are (with median ), (with median ), and (with median ). No two adjacent medians are equal.
More Info
Contributors
JAVA
Comments
Post a Comment