No.1061 Nice Sequence
タグ : / 解いたユーザー数 21
作問者 :
Enjapma_kyopro
/ テスター :
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もしくは右上の雲マークをクリックしてアカウントを作成してください。