P29752 [洛谷] [COCI2014-2015#6] KRATKI
普及+
题目描述

Problem Background

We are all familiar with the "Longest Monotonic Subsequence" problem:

Given a sequence of length $n$, you need to find the length of its LMS (Longest Monotonic Subsequence).
Note that the "LMS" here refers to the longer one between the increasing subsequence and the non-decreasing subsequence.
That is, you need to take the maximum length of LIS (Longest Increasing Subsequence) and LDS (Longest Decreasing Subsequence).

Now, you need to solve the inverse problem of LMS.

Problem Description

Given the length $n$ of a sequence.

You need to construct a permutation of length $n$ such that its LMS length is $k$.

Input Format

A single line containing two integers $n$ and $k$.

Output Format

If there is no solution, output -1.

Otherwise, output a single line containing $n$ integers, representing the constructed sequence.

If there are multiple solutions, output any one of them.

Sample Input and Output

Sample Input #1

4 3

Sample Output #1

1 4 2 3

Sample Input #2

5 1

Sample Output #2

-1

Sample Input #3

5 5

Sample Output #3

1 2 3 4 5

Notes

Sample 1 Explanation

The LMS of $\{1,4,2,3\}$ is $\{1,2,3\}$, with a length of $3$, which meets the requirement.

Data Size and Constraints

This problem uses a Special Judge.

For $100\%$ of the data, $1 \le k \le n \le 10^6$.

Notes

This problem is adapted from COCI 2014-2015 Contest #6 Task D KRATKI.

Due to the absence of certain special cases in the original data, additional data #11 has been added to this problem. If you fail to pass it, you will receive 120 Unaccept.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 3
样例输出
1 4 2 3