CSES Problemset/Introductory Problems
Permutations
#1070Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude DesktopA permutation of integers is called beautiful if there are no adjacent elements whose difference is .
Given , construct a beautiful permutation if such a permutation exists.
Input
The only input line contains an integer .
Output
Print a beautiful permutation of integers . If there are several solutions, you may print any of them. If there are no solutions, print "NO SOLUTION".
Constraints
Sample Test Cases (2)
Example 1ID: sample-1
Input
5
Expected Output
4 2 5 3 1
Example 2ID: sample-2
Input
3
Expected Output
NO SOLUTION
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|1 line, 0 charsTest Bench
Input (stdin)
5
Expected Output
4 2 5 3 1