#P7957. [COCI 2014/2015 #6] KRATKI
[COCI 2014/2015 #6] KRATKI
Background
We are all very familiar with the “Longest Monotone Subsequence” problem:
Given a sequence of length , 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.
Problem Description
Given the length of a sequence.
You need to construct a permutation of length such that its LMS length is .
Input Format
A single line with two integers .
Output Format
If there is no solution, output .
Otherwise, output one line with integers, the sequence you constructed.
If there are multiple solutions, output any one.
4 3
1 4 2 3
5 1
-1
5 5
1 2 3 4 5
Hint
Explanation of Sample 1
The LMS of is , with length , which meets the requirement.
Constraints
This problem uses Special Judge.
For of the testdata, .
Notes
According to the original settings, the full score is 120 points.
Translated from COCI 2014-2015 Contest #6 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