#P10032. 「Cfz Round 3」Mex of Sequence
「Cfz Round 3」Mex of Sequence
Problem Description
Please note the special time limit of this problem.
Given a sequence of length and an integer .
We define one operation as: simultaneously replace each element in sequence with the of all elements in sequence except .
You need to output the sequence after performing operations.
Here, the of a sequence is the smallest natural number that does not appear in the sequence. For example:
- .
- .
- .
- .
In particular, when the sequence is empty, its is .
Input Format
This problem has multiple test cases.
The first line contains an integer , the number of test cases.
Then the test cases follow. For each test case:
- The first line contains two integers .
- The second line contains integers, representing the given sequence .
Output Format
For each test case, output one line containing integers separated by spaces, representing the sequence after performing operations.
3
4 1
1 0 1 2
4 5
9 9 6 1
3 5
1 3 0
3 0 3 2
0 0 0 0
1 2 0
Hint
"Sample Explanation #1"
For the first test case, since , , , and , the sequence after performing operation is .
Constraints
Let be the sum of within a single test point.
For all testdata, , , , , and .
You can get the score for this problem only if you pass all test points.
Translated by ChatGPT 5