## A Permutation Problem 2

View as PDF

Points: 12
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Given 2 integers and , find the lexicographically largest permutation of such that it takes exactly swaps (between any two elements) to most efficiently sort it.

We define the most efficient sorting of an array of integers as one where the number of swaps is minimized.

The answer is guaranteed to exist.

#### Input Specification

The first and only line will contain integers, .

#### Output Specification

On one line, output the lexicographically greatest array that satisfies the conditions outlined in the problem statement.

#### Sample Input 1

4 3

#### Sample Output 1

4 3 1 2

• commented on Feb. 17, 2020, 9:01 p.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Feb. 16, 2020, 11:27 a.m.

Is it possible to not MLE in py3

• commented on Feb. 16, 2020, 12:27 p.m.

If you need a hint, try to use memory.

P.S. damn it c beat me to it.

• commented on Feb. 16, 2020, 12:14 p.m. edited