[Solution] Kevin and Permutation Codeforces Solution
For his birthday, Kevin received the set of pairwise distinct numbers as a gift.
He is going to arrange these numbers in a way such that the minimum absolute difference between two consecutive numbers be maximum possible. More formally, if he arranges numbers in order , he wants to maximize the value
Help Kevin to do that.
Each test consists of multiple test cases. The first line contains a single integer () — the number of test cases. Description of the test cases follows.
The only line of each test case contains an integer () — the size of the set.
For each test case print a single line containing distinct integers () describing the arrangement that maximizes the minimum absolute difference of consecutive elements.
Formally, you have to print a permutation which maximizes the value .
If there are multiple optimal solutions, print any of them.
In the first test case the minimum absolute difference of consecutive elements equals . It's easy to prove that this answer is optimal.
In the second test case each permutation of numbers is an optimal answer. The minimum absolute difference of consecutive elements equals to
No comments:
Post a Comment