2501.Optimal Number Permutation

Time Limit: 1s Memory Limit: 256MB

You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a.

Let number i be in positions xi,yi (xi \lt yi) in the permuted array a. Let's define the value di=yi-xi - the distance between the positions of the number i. Permute the numbers in array a to minimize the value of the sum 2501_1.png.

Input Format(From the terminal/stdin)

The only line contains integer n (1 \le n \le 5 \cdot 105).

Output Format(To the terminal/stdout)

Print 2n integers - the permuted array a that minimizes the value of the sum s.

Sample Input 1

Copy
2
 \n

Sample Output 1

Copy
1 1 2 2
 · · · \n

Sample Input 2

Copy
1
 \n

Sample Output 2

Copy
1 1
 · \n

Submit

请先 登录

© 2025 FAQs