CF864D Make a Permutation!

题目描述

### 题目大意 给出含有 $n$ 个数的序列,每个数的范围是 $1\sim n$。请你改变其中的一些数使这个序列成为一个 $1\sim n$ 的全排列,若有多种变化方案,取改变次数最少且字典序最小的方案。

输入格式

第一行一个整数 $n(2\le n\le 200000)$。 第二行 $n$ 个整数表示这个序列。

输出格式

第一行一个整数表示最少的改变次数。 第二行表示改变后的全排列 。 感谢@凌幽 提供的翻译

说明/提示

In the first example Ivan needs to replace number three in position $ 1 $ with number one, and number two in position $ 3 $ with number four. Then he will get a permutation \[1, 2, 4, 3\] with only two changed numbers — this permutation is lexicographically minimal among all suitable. In the second example Ivan does not need to change anything because his array already is a permutation.