atcoder#ABC253G. [ABC253G] Swap Many Times
[ABC253G] Swap Many Times
Score : points
Problem Statement
For an integer greater than or equal to , there are pairs of integers such that .
Consider the sequence of these pairs sorted in the increasing lexicographical order. Let be its -th, -th, , and -th elements, respectively. On a sequence , We will perform the following operation for in this order:
- Swap and .
Find the final after all the operations.
We say that is smaller than in the lexicographical order if and only if one of the following holds:
- and
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the terms of after all the operations in one line, separated by spaces.
5 3 6
5 1 2 3 4
Consider the sequence of pairs of integers such that sorted in the increasing lexicographical order. Its -rd, -th, -th, and -th elements are , respectively.
Corresponding to these pairs, transitions as follows.
$(1, 2, 3, 4, 5) \rightarrow (4, 2, 3, 1, 5) \rightarrow (5, 2, 3, 1, 4) \rightarrow (5, 3, 2, 1, 4) \rightarrow (5, 1, 2, 3, 4)$
10 12 36
1 10 9 8 7 4 3 2 5 6