Permutation

순열의 역전 개수와 뒤집은 순열의 역전 개수가 같은 순열을 안정하다고 할 때, 길이 n인 안정 순열 중 사전순으로 k번째 순열을 찾는다.

어려움8조합론동적 계획법수학구현아직 제출이 없습니다시간 제한3초메모리 제한256 MB

문제

A permutation of length nn is a sequence p_1,p_2,...p_np\_1, p\_2, ... p\_n, where p_i1,2,...,np\_i \in \\{1, 2, ..., n\\} and _ijp_ip_j\forall \_{i \neq j} p\_i \neq p\_j. We say that a pair (p_i,p_j)(p\_i, p\_j), where i<ji < j, is an inversion, if p_i>p_jp\_i > p\_j. We call a permutation stable, if the number of its inversions does not change after reversing the sequence comprising the permutation.

You are asked to find the kk-th stable permutation of length nn with respect to the lexicographic order.

입력

The only line of the input contains two integers n,kn, k (1n250,0001 \le n \le 250\\,000, 1k10181 \le k \le 10^{18}), denoting the length and the index (in the lexicographic order) of the sought stable permutation, respectively.

출력

If there exists such a permutation, in the first line you should output YES and in the second row, nn numbers p_1,,p_np\_1,\ldots,p\_n representing the sought permutation. Otherwise output NO.

힌트

There are 6 stable permutations of length 44: (1,4,3,2), (2,3,4,1), (2,4,1,3),(3,1,4,2), (3,2,1,4), (4,1,2,3).(1, 4, 3, 2),\ (2, 3, 4, 1),\ (2, 4, 1, 3),\  (3, 1, 4, 2),\ (3, 2, 1, 4),\ (4, 1, 2, 3).