4335: Beautiful Sequence

时间限制:1000 ms 内存限制:256 MB
上传者:
提交:2 通过:1

题目描述

We call a sequence A=(A1,A2,…,An) of length n beautiful when all the following conditions are true:
  •  A1A2An
  •  For each Ai (1in), 0Ai<230.
  •  For each 1≤i<nAiAi+1=B, where B is a given sequence, and  represents bitwise XOR.
You need to find the k-th smallest lexicographically legal beautiful sequence A.

输入格式

第一行两个整数 n,k.(1≤n≤106 ,1k230)
第二行n-1个整数 B1,B2,…,Bn−1 (0Bi<230)

输出格式

If the number of beautiful sequences is less than k, output one line containing an integer −1.
Otherwise, output one line containing n integers A1,A2,…,An separated by spaces --- the k-th smallest lexicographically legal beautiful sequence.

输入样例 复制

3 3
1 2

输出样例 复制

8 9 11