#P11171. 「CMOI R1」mex1
「CMOI R1」mex1
Background
Little U is very interested in functions that map a set to a number, and is a good example.
means 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_{S\neq \emptyset,S\subseteq \{1,2,...,n\}}\text{mex}(a_{S_1},a_{S_2},...,a_{S_{|S|}})=c$$where is required. It can be proven that within the constraints of this problem, if a solution exists, then a solution must exist for some .
Input Format
The first line contains an integer , the number of test cases.
Then there are lines, each containing a non-negative integer .
Output Format
For each test case:
If there is no solution, output only one line with an integer .
Otherwise, output a positive integer on the first line.
Output non-negative integers 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
is the index.
| Special Property | Score | Special Property | Score | ||
|---|---|---|---|---|---|
For of the testdata, , .
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