CF513B1.Permutations

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a permutation pp of numbers 1,2,...,n1,2,...,n . Let's define f(p)f(p) as the following sum:

Find the lexicographically mm -th permutation of length nn in the set of permutations having the maximum possible value of f(p)f(p) .

输入格式

The single line of input contains two integers nn and mm ( 1<=m<=cntn1<=m<=cnt_{n} ), where cntncnt_{n} is the number of permutations of length nn with maximum possible value of f(p)f(p) .

The problem consists of two subproblems. The subproblems have different constraints on the input. You will get some score for the correct submission of the subproblem. The description of the subproblems follows.

  • In subproblem B1 ( 33 points), the constraint 1<=n<=81<=n<=8 will hold.
  • In subproblem B2 ( 44 points), the constraint 1<=n<=501<=n<=50 will hold.

输出格式

Output nn number forming the required permutation.

输入输出样例

  • 输入#1

    2 2
    

    输出#1

    2 1 
    
  • 输入#2

    3 2
    

    输出#2

    1 3 2 
    

说明/提示

In the first example, both permutations of numbers {1, 2} yield maximum possible f(p)f(p) which is equal to 4. Among them, (2,1)(2,1) comes second in lexicographical order.

首页