#P5823. 【L&K R-03】课表的排列

【L&K R-03】课表的排列

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,12,3,1. After sorting these numbers from small to large, we get 1,2,31,2,3, which is an arithmetic sequence with common difference 11.

Little L wants to know whether a timetable with the same interesting property exists for more subjects. In other words, if there are nn 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 nn subjects from small to large, the result is an arithmetic sequence with common difference 11.

However, Little L can only write an algorithm with time complexity O((2n)!×nlog2n)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 nn, 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 2n2n integers representing the timetable. Let each integer in 1,2,,n1,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.

3
1 2 3 1 3 2

Hint

This problem uses Special Judge.

There are 2020 test points in total, and each test point is worth 55 points.

Data Index  x~x n=n=
1101\sim 10 2x+12x+1
111511\sim 15 200x+1200x+1
162016\sim 20 100000x+1100000x+1

Translated by ChatGPT 5