#P2528. [SHOI2001] 排序工作量之新任务
[SHOI2001] 排序工作量之新任务
Description
Suppose we define the parameter of the -th item as . Sorting means arranging in ascending order. If and , then is an “inversion pair.” The SORT company specializes in providing sorting services. Their pricing is based on the number of inversion pairs among the items to be sorted, called the “inversion count.”
Grant is a sorter at this company. He wants to know, among all sequences of items with distinct parameters, how many have inversion count , and to also provide one lexicographically smallest such sequence. “Smallest” means: for two sequences and , if there exists such that $(A_1,A_2,\cdots ,A_{i-1})=(B_1,B_2,\cdots ,B_{i-1})$ and .
Input Format
Two integers and (, ).
Output Format
- The first line contains the number of sequences of distinct items whose inversion count is .
- The second line is the requested sequence of item parameters. Assume the items are labeled to .
4 3
6
1 4 3 2
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号