[Solution] Best Permutation Codeforces Solution
Let's define the value of the permutation of integers , , ..., (a permutation is an array where each element from to occurs exactly once) as follows:
- initially, an integer variable is equal to ;
- if , then add to (set ), otherwise assign to ;
- if , then add to (set ), otherwise assign to ;
- ...
- if , then add to (set ), otherwise assign to ;
- the value of the permutation is at the end of this process.
For example, for , the value of changes as follows: , so the value of the permutation is .
You are given an integer . Find a permutation of size with the maximum possible value among all permutations of size . If there are several such permutations, you can print any of them.
The first line contains one integer () — the number of test cases.
The only line of each test case contains one integer ().
For each test case, print integers — the permutation of size with the maximum possible value among all permutations of size .
No comments:
Post a Comment