Problem Statement
You are given a positive integer $N$ and a sequence of $M$ positive integers $A = (A_{1}, A_{2}, \dots, A_{M})$.
Here, all elements of $A$ are distinct integers between $1$ and $N$, inclusive.
A permutation $P = (P_{1}, P_{2}, \dots, P_{N})$ of $(1, 2, \dots, N)$ is called a good permutation when it satisfies the following condition for all integers $i$ such that $1 \leq i \leq M$:
- No contiguous subsequence of
$P$is a permutation of$(1, 2, \dots, A_{i})$.
Determine whether a good permutation exists, and if it does, find the lexicographically smallest good permutation.
What is lexicographical order? A sequence $S = (S_1, S_2, \ldots, S_{|S|})$ is said to be lexicographically smaller than a sequence $T = (T_1, T_2, \ldots, T_{|T|})$ if one of the following conditions holds. Here, $|S|$ and $|T|$ denote the lengths of $S$ and $T$, respectively. $|S| \lt |T|$ and $(S_1, S_2, \ldots, S_{|S|}) = (T_1, T_2, \ldots, T_{|S|})$. There exists an integer $1 \leq i \leq \min\lbrace |S|, |T| \rbrace$ such that both of the following hold: $(S_1, S_2, \ldots, S_{i-1}) = (T_1, T_2, \ldots, T_{i-1})$. $S_i$ is smaller than $T_i$ (as a number).
Constraints
$1 \leq M \leq N \leq 2 \times 10^{5}$$1 \leq A_{i} \leq N$- All elements of
$A$are distinct. - All input values are integers.
Input
The input is given from Standard Input in the following format:
N M
A_{1} A_{2} \cdots A_{M}
Output
If a good permutation does not exist, print -1.
If it exists, print the lexicographically smallest good permutation, separated by spaces.
样例
4 1
2
1 3 2 4
5 3
4 3 2
1 3 4 5 2
92 4
16 7 1 67
-1
43 2
43 2
-1
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。