Logo
(追記) (追記ここまで)

33143번 - Inversion Insight 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.5 초 (추가 시간 없음) 2048 MB1912956.250%

문제

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 $N!$ permutations of the integers from 1ドル$ to $N$: 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 1ドル$ to $N!,ドル indicating its position in the sorted list of all $N!$ permutations.

Thus, the identity permutation $(1, 2, \dots , N),ドル which is the only permutation with zero inversions, is assigned the identifier 1ドル,ドル while the reverse identity permutation $(N, N - 1, \dots , 1),ドル which is the only one with the maximum number of inversions, is assigned the identifier $N!$.

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 $N$ and $K,ドル outputs the permutation of the integers from 1ドル$ to $N$ corresponding to identifier $K$.

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 $N$ elements, its number of inversions $\text{inv}(π)$ is defined as

$$\text{inv}(π) = |\{(i, j) : 1 ≤ i < j ≤ N ∧ π(i) > π(j)\}|$$

입력

The input consists of a single line that contains two integers $N$ (1ドル ≤ N ≤ 2 \cdot 10^5 $) and $K$ (1ドル ≤ K ≤ \min(N!, 4 \cdot 10^{18})$).

출력

Output a single line with $N$ integers, describing the $K$-th permutation of the integers from 1ドル$ to $N,ドル considering permutations sorted according to the university’s criteria.

제한

예제 입력 1

4 10

예제 출력 1

1 4 3 2

예제 입력 2

5 120

예제 출력 2

5 4 3 2 1

예제 입력 3

16 12345678901234

예제 출력 3

2 13 8 10 3 15 16 5 11 12 1 9 7 6 14 4

힌트

출처

ICPC > Regionals > Latin America > Latin America Regional Contests > Latin America Regional Contests 2024 I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /