luogu#P7902. 「PMOI-0」假·儒略日
「PMOI-0」假·儒略日
Background
(Originally LZOI-1, renamed with the consent of PMOI members.)
Lanuxhem heard that Yan Zhuo D solved Julian Day directly in the S-PSC exam room, and wanted to get the accepted code from Yan Zhuo D.
But Yan Zhuo D did not want to give it to him, so Yan Zhuo D threw the following problem to Lanuxhem and said, "Solve this problem and I will give it to you."
lhm-02
Problem Description
Given a positive integer and another positive integer .
You need to construct a sequence of length , satisfying:
- Every number from to appears exactly times.
- For a number , if is odd, then the difference between the positions of its two occurrences must be greater than .
- For a number , if is even, then the difference between the positions of its two occurrences must not be greater than .
Since Lanuxhem wants to get Yan Zhuo D's code but cannot solve this problem, he can only ask the smart you to help him finish it.
Input Format
The first line contains two integers and .
Output Format
If there is no solution, output -1. Otherwise, output a sequence of length as your answer.
If there are multiple solutions, any one of them will be accepted.
3 2
3 1 2 3 2 1
3 6
-1
Hint
Sample Explanation
The two occurrences of number are at positions , with difference .
The two occurrences of number are at positions , with difference .
The two occurrences of number are at positions , with difference .
Constraints
This problem uses bundled testdata.
| Subtask ID | Score | Special Constraint |
|---|---|---|
For of the testdata: 。
Translated by ChatGPT 5