No.1051 PQ Permutation
タグ : / 解いたユーザー数 49
作問者 :
stoq
/ テスター :
kakira9618
Apology
The test cases were weak, so a rejudge was performed. We apologize for the inconvenience.
Problem Statement
You are given a permutation $A$ of $1$ to $N$. Find the lexicographically smallest permutation $B$ of $1$ to $N$ that satisfies all of the following conditions.
If no such $B$ exists, output -1.
(Conditions)
・$B$ is strictly greater than $A$ in lexicographic order
・In $B$, $P$ is to the left of $Q$
Input
$N \ P \ Q$ $A_1\ A_2\ \dots \ A_N$
$2 \leq N \leq 2 \times 10^5$
$1 \leq P,Q \leq N$
$P \neq Q$
Each of $1$ to $N$ appears exactly once in $A_i$
Output
Output the permutation $B$ satisfying the conditions, separated by spaces. If it does not exist, output -1.
Do not put a space after the last element, and print a newline at the end.
Sample
Sample 1
Input
5 1 2
2 1 5 3 4
Output
3 1 2 4 5
Sample 2
Input
8 5 2
2 5 8 6 4 3 1 7
Output
3 1 4 5 2 6 7 8
Sample 3
Input
4 3 4
4 1 2 3
Output
-1
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。