#P11172. 「CMOI R1」mex2

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

「CMOI R1」mex2

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) is 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,\ldots,a_n \in [0,2\times 10^9] such that

$$\sum\limits_{1\le l\le r\le n}\text{mex}(a_l,a_{l+1},\ldots,a_r)=c$$

where it is required that 1n30001 \le n \le 3000. It can be proven that within the constraints of this problem, if a solution exists, then a solution must exist with 1n30001 \le n \le 3000.

Input Format

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

Then TT lines follow, each containing one non-negative integer cc.

Output Format

For each test case:

If there is no solution, output only one line containing 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,\ldots,a_n on the second line.

4
13
25
32
0
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

Hint

Sample Explanation

For sample #1: only mex(a7)=1\text{mex}(a_7)=1, and for all 1i61\le i\le6, we have mex(ai,ai+1,,a7)=2\text{mex}(a_i,a_{i+1},\ldots,a_7)=2, so the total sum is 1313.

Constraints

idid is the subtask\text{subtask} index.

idid Special Property Score idid Special Property Score
11 c3×103c\le3\times10^3 33 55 c8×106c\le8\times 10^6 1010
22 c6×103c\le6\times 10^3 77 66 c1×108c\le1\times 10^8
33 c8×104c\le8\times10^4 1010 77 c1×109c\le1\times 10^9 2525
44 c4×106c\le4\times 10^6 1515 88 c2×109c\le2\times 10^9 2020

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

Translated by ChatGPT 5