P5823 [L&K R-03] Timetable Arrangement

Background

Little L came to the classroom in the morning and found today’s timetable very interesting.

Description

Today’s timetable is: Chinese Math English Chinese English Math There are three subjects on today’s timetable: Chinese, Math, and English. Each subject has two classes. For each subject, the number of classes between its two occurrences is $2,3,1$. After sorting these numbers from small to large, we get $1,2,3$, which is an arithmetic sequence with common difference $1$. Little L wants to know whether a timetable with the same interesting property exists for more subjects. In other words, if there are $n$ subjects on the timetable, and each subject appears exactly twice, Little L wants to know whether there exists a timetable such that, after sorting the numbers of classes between the two classes of each of the $n$ subjects from small to large, the result is an arithmetic sequence with common difference $1$. However, Little L can only write an algorithm with time complexity $O((2n)!\times n\log_2 n)$, so he asks you for help. You need to determine whether such a timetable exists. If it exists, you also need to output one possible timetable.

Input Format

The input contains only one line: an **odd** integer $n$, representing the number of subjects on the timetable.

Output Format

Output only one line. If no such timetable exists, output `-1`. If such a timetable exists, output $2n$ integers representing the timetable. Let each integer in $1,2,\ldots,n$ correspond to one subject. Each integer appears exactly twice in the timetable, and the timetable must satisfy Little L’s property. Since there may be multiple valid answers, you may output any one. Little K, who has just arrived at the classroom, will write a program to check whether your timetable satisfies Little L’s property.

Explanation/Hint

**This problem uses Special Judge.** There are $20$ test points in total, and each test point is worth $5$ points. | Data Index $~x$ | $n=$ | | :-----------: | :-----------: | | $1\sim 10$ | $2x+1$ | | $11\sim 15$ | $200x+1$ | | $16\sim 20$ | $100000x+1$ | Translated by ChatGPT 5