#P11172. 「CMOI R1」mex2
「CMOI R1」mex2
Background
Little U is very interested in functions that map a set to a number, and is a good example.
is the smallest non-negative integer that does not appear in the set .
Problem Description
Multiple test cases.
For each test case, given , you need to construct a sequence 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 . It can be proven that within the constraints of this problem, if a solution exists, then a solution must exist with .
Input Format
The first line contains an integer , the number of test cases.
Then lines follow, each containing one non-negative integer .
Output Format
For each test case:
If there is no solution, output only one line containing an integer .
Otherwise, output a positive integer on the first line.
Output non-negative integers 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 , and for all , we have , so the total sum is .
Constraints
is the index.
| Special Property | Score | Special Property | Score | ||
|---|---|---|---|---|---|
For of the testdata, , .
Translated by ChatGPT 5