問題一覧 > 通常問題

No.478 General Kadomatsu Sequence Sequence

レベル : / AI推定難易度 : 725 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 223
作問者 : mai
お気に入りにしたユーザー ProblemId : 1489 / 自分の提出
問題文最終更新日: 2026-06-28 09:26:07
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 155 (順位表) の他の問題:

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.

  1. $a_1,a_2,a_3$ are all distinct
  2. 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もしくは右上の雲マークをクリックしてアカウントを作成してください。