From one to en (3)

Write a program that prints all the permutations of {1,,n}\{ 1, \dots, n \} with kk inversions, for a given nn and kk. An inversion is a pair of elements xx and yy such that x>yx > y and such that xx appears before yy in the permutation.

Input

Input consists of two natural numbers nn and kk, such that n1n \ge 1 and 0kn(n1)/20 \le k \le n(n - 1)/2.

Output

Print all the permutations of {1,,n}\{ 1, \dots, n \} with kk inversions.

Information about the checker

You can print the solutions to this exercise in any order.

Hint

Here, a very simple algorithm may be too slow.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:39:59.304Z

© Jutge.org, 2006–2026.
https://jutge.org