B) The Permutation Game

0

0 votes
Permutation and combination, Implementation
Problem

Bob likes playing with permutations.Alice asks him to play a game.She gave him two integers n and x.Now, she asks Bob to find the xth ranked permutation of length n.

A permutation of length n is a sequence of size n consisting of n distinct integers in the range [1, n].

Input Format

The only line of the input contains 2 space separated integers n and x.

Output Format

Print n space separated integers which represent xth ranked permutation.

Constraints

1<=n<=18

1<=x<=1018

Note : It is guaranteed that answer exists for the given input.

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?