問題一覧 > 通常問題

No.3267 PQ Straight

レベル : / AI推定難易度 : 1150 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 83
作問者 : apricity / テスター : 👑 qand
お気に入りにしたユーザー ProblemId : 12499 / 自分の提出
問題文最終更新日: 2025-09-12 02:55:59
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 482 (順位表) の他の問題:

Problem Statement

You are given an integer $N$ greater than or equal to $2$. Determine whether there exists a pair $(P = (P_1, P_2,\dots, P_N), Q = (Q_1, Q_2,\dots, Q_N))$ of permutations of $(1,2,\dots,N)$ satisfying the following condition, and if one exists, show an example.

  • The sequence $S = (S_1, S_2,\dots, S_N)$ of length $N$ defined by $S_i = P_i + Q_i \hspace{.5em} (i = 1, 2,\dots, N)$ is an arithmetic progression with common difference $1$.

Input

$N$

  • $N$ is an integer satisfying $2\le N \le 2\times 10^5$.

Output

If no pair $(P,Q)$ satisfying the condition exists, print No. If one exists, print Yes on the first line, $P$ on the second line, and $Q$ on the third line, in the following format.

Yes
$P_1\ P_2\ \dots\ P_N$
$Q_1\ Q_2\ \dots\ Q_N$
If there are multiple pairs satisfying the condition, any of them will be accepted.

Sample

Sample 1
Input
2
Output
No

No pair $(P,Q)$ satisfying the condition exists.

Sample 2
Input
3
Output
Yes
1 3 2
2 1 3

For $P = (1,3,2), Q = (2,1,3)$, $S = (3,4,5)$ is an arithmetic progression with common difference $1$.

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