CSES - Permutations
Xem dạng PDF
Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
512M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
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
- The only input line contains an integer ~n~.
Output
- 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".
Constraints
- ~1 \le n \le 10^6~
Example Input 1
5
Example Output 1
4 2 5 3 1
Example Input 2
3
Example Output 2
NO SOLUTION
Bình luận