6769.Permutations

Time Limit: 1s Memory Limit: 512MB

A permutation of integers $1,2,\ldots,n$ is called beautiful if there are no adjacent elements whose difference is $1$ .

Given $n$ , construct a beautiful permutation if such a permutation exists.

Input Format(From the terminal/stdin)

The only input line contains an integer $n$ .

  • $1 \le n \le 10^6$

Output Format(To the terminal/stdout)

Print a beautiful permutation of integers $1,2,\ldots,n$ . If there are several solutions, you may print any of them. If there are no solutions, print "NO SOLUTION".

Sample Input 1

Copy
5
 \n

Sample Output 1 special judge

Copy
4 2 5 3 1
 · · · · \n

Sample Input 2

Copy
3
 \n

Sample Output 2 special judge

Copy
NO SOLUTION
  ·        \n
Source: CSES, Introductory Problems, 1070

Submit

请先 登录

© 2025 FAQs