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 nn and another positive integer dd.

You need to construct a sequence {a2n}\{a_{2n}\} of length 2n2n, satisfying:

  1. Every number from 11 to nn appears exactly 22 times.
  2. For a number ii, if ii is odd, then the difference between the positions of its two occurrences must be greater than dd.
  3. For a number ii, if ii is even, then the difference between the positions of its two occurrences must not be greater than dd.

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 nn and dd.

Output Format

If there is no solution, output -1. Otherwise, output a sequence of length 2n2n 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 11 are at positions 2,62,6, with difference 4(>2)4(>2).

The two occurrences of number 33 are at positions 1,41,4, with difference 3(>2)3(>2).

The two occurrences of number 22 are at positions 3,53,5, with difference 2(2)2(\le2).

Constraints

This problem uses bundled testdata.

Subtask ID Score Special Constraint
11 3636 n10n\le10
22 2424 d=n2d=\left\lfloor\dfrac{n}{2}\right\rfloor
33 4040 ×\times

For 100%100\% of the testdata: 1d2n1061\le\dfrac{d}{2}\le n\le10^6

Translated by ChatGPT 5