#P11171. 「CMOI R1」mex1

    ID: 11721 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数学2024洛谷原创Special JudgeO2优化深度优先搜索 DFS剪枝构造

「CMOI R1」mex1

Background

Little U is very interested in functions that map a set to a number, and mex\text{mex} is a good example.

mex(S)\text{mex}(S) means the smallest non-negative integer that does not appear in the set SS.

Problem Description

Multiple test cases.

For each test case, given cc, you need to construct a sequence a1,a2,...,an[0,2×109]a_1,a_2,...,a_n\in [0,2\times 10^9] such that

$$\sum\limits_{S\neq \emptyset,S\subseteq \{1,2,...,n\}}\text{mex}(a_{S_1},a_{S_2},...,a_{S_{|S|}})=c$$

where 1n401\le n\le 40 is required. It can be proven that within the constraints of this problem, if a solution exists, then a solution must exist for some 1n401\le n\le 40.

Input Format

The first line contains an integer TT, the number of test cases.

Then there are TT lines, each containing a non-negative integer cc.

Output Format

For each test case:

If there is no solution, output only one line with an integer 1-1.

Otherwise, output a positive integer nn on the first line.

Output nn non-negative integers a1,a2,...,ana_1,a_2,...,a_n on the second line.

5
120
8128
248
0
5
7
1 9 1 9 8 1 0
13
1 1 4 5 1 4 1 9 1 9 8 1 0
8
1 2 3 9 0 7 3 8
7
1 2 3 9 7 3 8
-1

Hint

Sample Explanation

I have a wonderful explanation, but unfortunately it cannot fit here.

Constraints

idid is the subtask\text{subtask} index.

idid Special Property Score idid Special Property Score
11 c10c\le10 33 66 c1×106c\le1\times 10^6 1515
22 c30c\le30 66 77 T10T\le 10 55
33 c500c\le500 88 T5×104T\le 5\times 10^4 1515
44 c2×103c\le2\times 10^3 55 99 T8×104T\le 8\times 10^4 1010
55 c1×105c\le1\times 10^5 2020 1010 1515

For 100%100\% of the testdata, T105T\le 10^5, 0c2×1090\le c\le 2\times 10^9.

Tips

Because the constants of some STL implementations are large, if you believe your time complexity is fine but you get TLE, please do not use STL.

Please pay attention to output efficiency. Here is a fast output template (please do not use the code below to output negative numbers):

void write(int x){
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

Translated by ChatGPT 5