P7957 [COCI 2014/2015 #6] KRATKI
Background
We are all very familiar with the “Longest Monotone Subsequence” problem:
> Given a sequence of length $n$, you need to find the length of its LMS (i.e., the longest monotone subsequence).
> **Note** that here “LMS” means **the longer one** between the increasing subsequence and the decreasing subsequence.
> That is, you need to take the maximum of the lengths of LIS and LDS.
Now you need to solve an inverse problem of LMS.
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 with two integers $n, k$.
Output Format
If there is no solution, output $\texttt{-1}$.
Otherwise, output one line with $n$ integers, the sequence you constructed.
**If there are multiple solutions, output any one.**
Explanation/Hint
#### Explanation of Sample 1
The **LMS** of $\{1,4,2,3\}$ is $\{1,2,3\}$, with length $3$, which meets the requirement.
#### Constraints
**This problem uses Special Judge.**
For $100\%$ of the testdata, $1 \le k \le n \le 10^6$.
#### Notes
According to the original settings, the full score is 120 points.
Translated from **[COCI 2014-2015](https://hsin.hr/coci/archive/2014_2015/)** [Contest #6](https://hsin.hr/coci/archive/2014_2015/contest6_tasks.pdf) Task D _**KRATKI**_.
Since the original testdata lacked some special cases, testdata #11 has been added to this problem. If you do not pass it, you will get 120 Unaccept.
Translated by ChatGPT 5