問題一覧 > 通常問題

No.1061 Nice Sequence

レベル : / AI推定難易度 : 2275 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 21
作問者 : Enjapma_kyopro / テスター : Mister
お気に入りにしたユーザー ProblemId : 4260 / 自分の提出
問題文最終更新日: 2020-05-19 01:29:51
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 249 (順位表) の他の問題:

Problem Statement

A sequence of integers of length $3N$ that satisfies the following condition is called a "nice sequence".

Condition: For every $i$ $(0 \le i \le N-1)$, both of the following hold.

  • $i$ appears exactly $3$ times in the sequence.
  • The absolute difference between "the number of elements between the $1$st occurrence of $i$ and the $2$nd occurrence of $i$" and
    "the number of elements between the $2$nd occurrence of $i$ and the $3$rd occurrence of $i$" is exactly $i$.

Given $N$, output $1$ "nice sequence".
If there are multiple, you may output any of them.
If none exists, output $-1$.

Input

$N$

  • $N$ is an integer between $1$ and $10^5$, inclusive.

Output

If a "nice sequence" exists, output its $3N$ elements in order starting from term $1$, separated by half-width spaces.
If there are multiple, you may output any of them.
If none exists, output $-1$.
Print a newline at the end.

Sample

Sample 1
Input
1
Output
0 0 0

Between the $1$st $0$ and the $2$nd $0$, there are $0$ elements.
Between the $2$nd $0$ and the $3$rd $0$, there are $0$ elements.
The difference is $0$, so the condition is satisfied.

Sample 2
Input
2
Output
-1

Sample 3
Input
3
Output
2 0 2 1 0 1 2 0 1

The numbers of elements between the occurrences of $0$ are $2$ and $2$; the difference is $0$, so the condition is satisfied.
The numbers of elements between the occurrences of $1$ are $1$ and $2$; the difference is $1$, so the condition is satisfied.
The numbers of elements between the occurrences of $2$ are $1$ and $3$; the difference is $2$, so the condition is satisfied.

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