No.478 General Kadomatsu Sequence Sequence
タグ : / 解いたユーザー数 223
作問者 :
Problem Statement
It has been handed down that a sequence $v = (a_1,a_2,a_3)$ consisting of 3 elements is a Kadomatsu sequence when $v$ satisfies the following conditions.
- $a_1,a_2,a_3$ are all distinct
- Among the 3 elements, $a_2$ is the largest or the smallest
Furthermore, a sequence $w = (a_1,...,a_n)$ consisting of $n$ elements (where $3\le n$) is called
a Kadomatsu sequence sequence when any 3 consecutive elements taken from $w$ form a Kadomatsu sequence.
For example, the sequence $(2,0,1,7,0,1)$ is not a Kadomatsu sequence sequence, because the Kadomatsu sequence condition fails exactly when taking the 3 consecutive elements starting from the 2nd element from the left.
Since that is a pity, let us consider a definition under which this sequence can also be called a Kadomatsu sequence sequence.
We call a sequence of $n$ elements in which "exactly $n-k-2$ of the groups of $3$ consecutive elements form a Kadomatsu sequence" a $一般門松列列_{n,k}$ (general Kadomatsu sequence sequence).
That is, $(2,0,1,7,0,1)$ is a $一般門松列列_{6,1}$.
Natural numbers $n$ and $k$ are given.
Output one sequence that satisfies $一般門松列列_{n,k}$. If no such sequence exists, output -1.
Input
n k
$3 \le n \le 20171$
$0 \le k \le n-2$
Output
Output one sequence satisfying $一般門松列列_{n,k}$, separated by spaces or by newlines.
The elements of the output sequence must be integers within the range from $0$ to $10^9$, inclusive.
Print a newline at the end.
A special judge written in C++14 is used.
In cases where multiple solutions exist, any of them will be accepted.
Sample
Sample 1
Input
6 1
Output
2 0 1 7 0 1
This is the case from the problem statement.
Outputting a $一般門松列列_{6,1}$ other than the one shown above, for example "2 9 0 1 0 2", is also correct.
Sample 2
Input
5 3
Output
1 2 4 8 16
Output a sequence in which no 3 consecutive elements form a Kadomatsu sequence.
Sample 3
Input
8 0
Output
1 3 2 4 1 3 2 4
When $k=0$, it is a Kadomatsu sequence sequence.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。