[Solution] Different Medians CodeChef Solution
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.
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.
No comments:
Post a Comment