#P3672. 小清新签到题

    ID: 2669 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划,dp贪心洛谷原创O2优化枚举,暴力前缀和洛谷月赛

小清新签到题

Description

Let's keep the problem simple.

Given natural numbers nn, kk, xx, you are required to find the kk-th smallest permutation a1,a2...ana_1,a_2 ... a_n of 1n1\sim n of length nn whose number of inversions is xx and then solve the problem using an on-cactus online branch-and-bound heuristic blossom-tree min-cost flow with bounds, and it is guaranteed to exist.

Note: An inversion is a pair (i,j)(i,j) such that i<ji<j and ai>aja_i>a_j. The comparison is lexicographical, i.e., compare from left to right at the first position where they differ. The kk-th smallest is 1-indexed. A permutation of 1n1\sim n is defined as a length-nn sequence that, after sorting, becomes 1n1\sim n.

Input Format

One line with three natural numbers nn, kk, xx.

Output Format

Output a permutation that satisfies the conditions: one line with nn numbers, separated by spaces.

3 2 2
3 1 2
10 6 4
1 2 3 4 5 7 6 10 9 8
50 233 233
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 32 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 33 35 34 31 30 29 28
50 233333333 333
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 43 49 50 47 46 45 48 44 41 42 40 39 37 38 36 35 34 33 32 30 29 31 28 25 26 27 24

Hint

For 10%10\% of the testdata, n8n \leq 8.

For 30%30\% of the testdata, n10n \leq 10.

For 50%50\% of the testdata, n50n \leq 50.

For an additional 20%20\% of the testdata, k=1k=1.

For 100%100\% of the testdata, 1n3001 \leq n \leq 300, 1k10131 \leq k \leq 10^{13}, and a valid permutation is guaranteed to exist.

Translated by ChatGPT 5