#4981. Problem 2. Making Mexes
0
Problem 2. Making Mexes
Problem 2. Making Mexes
USACO 2025 February Contest, Bronze
You are given an array of non-negative integers (). In one operation, you can change any element of to any non-negative integer.
The
mex
of an array is the minimum non-negative integer that it does not contain. For each in the range to inclusive, compute the minimum number of operations you need in order to make the mex of equal .
INPUT FORMAT (input arrives from the terminal / stdin):
The first line contains .
The next line contains .
OUTPUT FORMAT (print output to the terminal / stdout):
For each in the range to , output the minimum number of operations for on a new line. Note that it is always possible to make the mex of equal to any in the range to .
SAMPLE INPUT:
4 2 2 2 0
SAMPLE OUTPUT:
1 0 3 1 2
- To make the mex of equal to , we can change to (or any positive integer). In the resulting array, , is the smallest non-negative integer that the array does not contain, so is the mex of the array.
- To make the mex of equal to , we don't need to make any changes since is already the smallest non-negative integer that does not contain.
- To make the mex of equal to , we need to change the first three elements of . For example, we can change to be .
SCORING: Inputs 2-6: Inputs 7-11: No additional constraints.
Problem credits: Benjamin Qi