問題一覧 > 通常問題

No.3287 Golden Ring

レベル : / AI推定難易度 : 825 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 106
作問者 : kona0001 / テスター : tobisatis RyosukeFukatani koba-e964 ir5 drken1215
お気に入りにしたユーザー ProblemId : 12632 / 自分の提出
問題文最終更新日: 2025-10-03 00:12:21
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 485 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。