A Harder Contest '19 - A Permutation Problem 2

View as PDF

Submit solution

Points: 15
Time limit: 1.0s
Python 1.5s
Memory limit: 32M
Python 160M

Author:
Problem type

Given 2 integers N and K, find the lexicographically largest permutation of 1 \ldots N such that it takes exactly K 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 2 integers, N (1 \leq N \leq 10^6), K (0 \leq K \leq 10^6).

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

Comments

There are no comments at the moment.