No.3287 Golden Ring
Problem Statement
For an array of length at least $2$ arranged on a circle, we define it as a golden ring if "no two sums of adjacent elements are the same". That is, an array $A$ satisfying all of the following conditions is a golden ring.
- $2 \le N$
- $A$ is an array of length $N$
- $S_i = A_i + A_{i+1}$ $(1 \le i \le N-1)$
- $S_N = A_N + A_1$
- If $i \ne j$, then $S_i \ne S_j$
You are given the array $(1,2,...,N)$ consisting of the numbers from $1$ to $N$ in order. Determine whether a golden ring can be made by freely rearranging this array. If it can, find such an array.
Constraints
- $2 \le N \le 2000$
- $N$ is an integer
Input
The input is given from standard input in the following format.
$N$
Output
If an array $A$ that is a golden ring can be made, output the answer in the following format.
Yes $A_1\ A_2 \ldots\ A_N$
If there are multiple solutions, any of them will be accepted.
If it is impossible, output No. Print a newline at the end.
Sample
Sample 1
Input
4
Output
Yes 1 3 4 2
By rearranging into $A=(1,3,4,2)$, the sums of adjacent elements are $1+3=4$, $3+4=7$, $4+2=6$, and $2+1=3$, giving $S=(4,7,6,3)$. Since no value appears more than once in $S$, this array is a golden ring.
Other arrays such as $A=(4,2,1,3)$ also satisfy the conditions and will be accepted.
If $A=(1,2,3,4)$, then $S=(3,5,7,5)$, which contains a duplicate value, so it will be judged incorrect.
Sample 2
Input
5
Output
Yes 2 4 5 3 1
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
kona0001
drken1215