No.2719 Equal Inner Products in Permutation
タグ : / 解いたユーザー数 44
作問者 :
hamamu
👑 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もしくは右上の雲マークをクリックしてアカウントを作成してください。