#P1375D. Replace by MEX
Replace by MEX
Description
You're given an array of integers between and inclusive.
In one operation, you can choose any element of the array and replace it by the MEX of the elements of the array (which may change after the operation).
For example, if the current array is , you can choose the second element and replace it by the MEX of the present elements — . Array will become .
You must make the array non-decreasing, using at most operations.
It can be proven that it is always possible. Please note that you do not have to minimize the number of operations. If there are many solutions, you can print any of them.
–
An array is non-decreasing if and only if .
The MEX (minimum excluded) of an array is the smallest non-negative integer that does not belong to the array. For instance:
- The MEX of is , because does not belong to the array.
- The MEX of is , because and belong to the array, but does not.
- The MEX of is because , , and belong to the array, but does not.
It's worth mentioning that the MEX of an array of length is always between and inclusive.
The first line contains a single integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer () — length of the array.
The second line of each test case contains integers () — elements of the array. Note that they don't have to be distinct.
It is guaranteed that the sum of over all test cases doesn't exceed .
For each test case, you must output two lines:
The first line must contain a single integer () — the number of operations you perform.
The second line must contain integers (), where is the index chosen for the -th operation.
If there are many solutions, you can find any of them. Please remember that it is not required to minimize .
Input
The first line contains a single integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer () — length of the array.
The second line of each test case contains integers () — elements of the array. Note that they don't have to be distinct.
It is guaranteed that the sum of over all test cases doesn't exceed .
Output
For each test case, you must output two lines:
The first line must contain a single integer () — the number of operations you perform.
The second line must contain integers (), where is the index chosen for the -th operation.
If there are many solutions, you can find any of them. Please remember that it is not required to minimize .
Note
In the first test case, the array is already non-decreasing ().
Explanation of the second test case (the element modified by each operation is colored in red):
- ; the initial MEX is .
- ; the new MEX is .
- ; the new MEX is .
- The final array is non-decreasing: .
Explanation of the third test case:
- ; the initial MEX is .
- ; the new MEX is .
- ; the new MEX is .
- ; the new MEX is .
- ; the new MEX is .
- The final array is non-decreasing: .