P17623 [qaswed12 OI R1] Xor in Mex

题目背景

还有第二关?

题目描述

qaswed12 想让你构造一个长度为 $n$ 的整数序列 $a$,使得: - 对于任意 $1 \le i \le n$,有 $0 \le a_i \le n.$ - $k=\bigoplus\limits_{l=1}^{n}\bigoplus\limits_{r=l}^{n}\operatorname{mex}(l,r)$. 其中 $k$ 是给定的值。 $\operatorname{mex}(l,r)$ 定义为在 $a_l,a_{l+1},...,a_r$ 中未出现的最小非负整数。 $\bigoplus$ 符号与 $\sum$ 符号的定义类似,求和变为求异或和,以及 $\oplus$ 符号表示两数按位异或。 若有多个满足条件的方案,输出任意一个即可。无解输出 `-1`。

输入格式

一行两个整数 $n,k$。

输出格式

输出一行表示你构造的序列 $a$,用空格分开,无解请输出 `-1`。

说明/提示

### 样例解释 #1 $ \begin{aligned} & \bigoplus\limits_{l=1}^{3}\bigoplus\limits_{r=l}^{3}\operatorname{mex}(l,r) \\ = & \operatorname{mex}(1,1) \oplus \operatorname{mex}(1,2) \oplus \operatorname{mex}(1,3) \oplus \operatorname{mex}(2,2) \oplus \operatorname{mex}(2,3) \oplus \operatorname{mex}(3,3) \\ = & \,0 \oplus 2 \oplus 2 \oplus 1 \oplus 2 \oplus 0 \\ = & \,3 \end{aligned} $ ### 数据范围 **本题开启捆绑测试。** |子任务编号|$n$ |$k$|特殊性质|得分| |:--------:|:-:|:-:|:-:|:-:| |$1$|$\le 8$|$\le 16$|无|$4$| |$2$|$\le 1000$|$\le 3$|$n$ 为偶数|$12$| |$3$|^|^|无|$16$| |$4$|$\le 10^5$|$=0$|^|$4$| |$5$|^|$\le \lceil \frac{n}{2} \rceil$|^|$12$| |$6$|^|$=n$|^|$16$| |$7$|$\le 5 \times 10^5$|$\le 10^9$|$n$ 为偶数|$16$| |$8$|^|^|无|$20$| 对于 $100\%$ 的数据,满足 $1\le n\le 5 \times 10^5$,$0\le k\le 10^{9}$。