#P14127. [SCCPC 2021] K-skip Permutation

[SCCPC 2021] K-skip Permutation

题目描述

For a permutation P=p1,p2,,pnP = p_1, p_2, \cdots, p_n of nn, let f(P,k)f(P, k) be the number of ii satisfying 1i<n1 \le i < n and pi+k=pi+1p_i + k = p_{i+1}.

Given two integers nn and kk, your task is to find a permutation PP of nn such that f(P,k)f(P, k) is maximized.

Recall that in a permutation of nn, each integer from 11 to nn (both inclusive) appears exactly once.

输入格式

There is only one test case in each test file.

The first and only line contains two integers nn and kk (1n,k1061 \le n, k \le 10^6).

输出格式

Output one line containing nn integers indicating a permutation PP of nn that maximizes f(P,k)f(P, k). If there are multiple valid answers you can output any of them.

Please, DO NOT output extra spaces at the end of the line, or your answer may be considered incorrect!

3 1
1 2 3
7 3
2 5 1 4 7 3 6
3 7
1 3 2