Inversion Insight
시간 제한0.5초메모리 제한2048 MB
1부터 N까지의 모든 순열을 반전 수 오름차순으로, 같으면 사전순으로 정렬했을 때 K번째 순열을 구해 출력한다.
문제
In MathemIsland, the wildlife is very diverse. There are roots, trees, leaves, pigeons – everything you’d find in a math book. And everywhere you look, there is a permutation.
ICPC University has devised a systematic way to catalog these permutations. Specifically, because inversions are of utmost importance in studying wildlife genetics, ICPC University has decided to sort all permutations of the integers from to : first by the number of inversions and, in the case of a tie, by lexicographic order. This approach uniquely identifies each permutation by an integer from to , indicating its position in the sorted list of all permutations.
Thus, the identity permutation , which is the only permutation with zero inversions, is assigned the identifier , while the reverse identity permutation , which is the only one with the maximum number of inversions, is assigned the identifier .
As part of the team implementing the ICPC University database, your task is to retrieve a specific permutation based on its identifier. Write a program that, given two integers and , outputs the permutation of the integers from to corresponding to identifier .
Remember that the number of inversions in a permutation is the number of pairs of elements that are out of their natural order. That is, for a permutation with elements, its number of inversions is defined as
입력
The input consists of a single line that contains two integers () and ().
출력
Output a single line with integers, describing the -th permutation of the integers from to , considering permutations sorted according to the university’s criteria.