当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2085:Inversion

题目描述
The inversion number of an integer sequence a1, a2, . . . , an is the number of pairs (ai, aj) that satisfy i < j and ai > aj . Given n and the inversion number m, your task is to find the smallest permutation of the set { 1, 2, . . . , n }, whose inversion number is exactly m.
A permutation a1, a2, . . . , an is smaller than b1, b2, . . . , bn if and only if there exists an integer k such that aj = bj for 1 <= j < k but ak < bk.
输入解释
The input consists of several test cases. Each line of the input contains two integers n and m. Both of the integers at the last line of the input is −1, which should not be processed. You may assume that 1 <= n <= 50000 and 0 <= m <= n(n − 1)/2.
输出解释
For each test case, print a line containing the smallest permutation as described above, separates the numbers by single spaces.
输入样例
5 9
7 3
-1 -1
输出样例
4 5 3 2 1
1 2 3 4 7 6 5

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2085

最后修改于 2020-10-29T06:22:55+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 30000