問題一覧 > 通常問題

No.2719 Equal Inner Products in Permutation

レベル : / AI推定難易度 : 2000 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 44
作問者 : ecottea / テスター : 👑 hamamu 👑 AngrySadEight
お気に入りにしたユーザー ProblemId : 10616 / 自分の提出
問題文最終更新日: 2024-03-30 16:18:45
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 426 (順位表) の他の問題:

Problem Statement

You are given a positive integer $N$. A permutation $P = (P_1, P_2, \ldots, P_{3N})$ of $1,2,\ldots,3N$ is called a good permutation if it satisfies the following condition:

  • $\sum_{i=1}^N P_i P_{N+i} = \sum_{i=1}^N P_{N+i} P_{2N+i}$

Determine whether a good permutation exists, and if so, construct $1$ example of one.

Constraints

  • $1 \leq N \leq 2 \times 10^5$
  • The input consists of integers.

Input

The input is given from standard input in the following format.

$N$

Output

If a good permutation $P$ exists, print $P_1, \ldots, P_{3N}$ in this order on a single line, separated by single spaces. If none exists, print -1.
Print a newline at the end.

Sample

Sample 1
Input
3
Output
1 2 8 3 6 9 7 5 4

$$ \sum_{i=1}^3 P_i P_{3+i} = 1 \times 3 + 2 \times 6 + 8 \times 9 = 3 + 12 + 72 = 87\\ \sum_{i=1}^3 P_{3+i} P_{6+i} = 3 \times 7 + 6 \times 5 + 9 \times 4 = 21 + 30 + 36 = 87 $$ Since the two are equal, $P = (1, 2, 8, 3, 6, 9, 7, 5, 4)$ is a good permutation.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。