AtCoder Regular Contest 140
C
ABS Permutation (LIS ver.)
AtCoder
⌀ 1596
原题
← BD →
翻译中…

Problem Statement

翻译中…

The happiness of a permutation $P=(P_1,P_2,\ldots,P_N)$ of $(1,\dots,N)$ is defined as follows.

翻译中…
  • Let $A=(A_1,A_2,\ldots,A_{N-1})$ be a sequence of length $N-1$ with $A_i = |P_i-P_{i+1}|(1\leq i \leq N-1)$. The happiness of $P$ is the length of a longest strictly increasing subsequence of $A$.
翻译中…

Print a permutation $P$ such that $P_1 = X$ with the greatest happiness.

翻译中…

Constraints

翻译中…
  • $2 \leq N \leq 2\times 10^5$
  • $1 \leq X \leq N$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N X

翻译中…

Output

翻译中…

Print a permutation $P$ such that $P_1 = X$ with the greatest happiness, in the following format:

翻译中…

P_1 P_2 \ldots P_N

翻译中…

If there are multiple solutions, printing any of them will be accepted.

翻译中…

样例

Input #1
3 2
Output #1
2 1 3
Since $A=(1,2)$, the happiness of $P$ is $2$, which is the greatest happiness achievable, so the output meets the requirement.
Input #2
3 1
Output #2
1 2 3
Since $A=(1,1)$, the happiness of $P$ is $1$, which is the greatest happiness achievable, so the output meets the requirement.
题目信息
题号
arc140_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。