Largest Increasing Subsequence

All submissions for this problem are available.
Petya is preparing a problem for a local contest in his school. The problem is to find a longest increasing subsequence in a given permutation. A *permutation* of size $n$ is a sequence of $n$ numbers $a_1, \ldots, a_n$ such that every number from $1$ to $n$ occurs in the sequence exactly once. An *increasing subsequence* of length $k$ of the sequence $a_1, \ldots, a_n$ is a sequence of indices $i_1, \ldots, i_k$ such that $1 \leq i_1 < \ldots < i_k \leq n$ and $a_{i_1} < \ldots < a_{i_k}$. A longest increasing subsequence is an increasing subsequences with the largest length. Note that in general there may be several longest increasing subsequences. Petya had some tests prepared, but then lost the input part for some of them. He now has a test for a certain value of $n$, and a sequence $i_1, \ldots, i_k$ that is supposed to be a longest increasing subsequence. Petya now has to reconstruct a permutation of size $n$ with this sequence being an answer. Petya doesn't want to take any risks, so he additionally wants this sequence to be the **only** longest increasing subsequence, that is, all other increasing subsequences have to have **strictly smaller** length. Help Petya determine if this is possible, and if so, construct any such permutation. ###Input: The first line contains an integer $T$, denoting number of test cases. The first line of every test case contains two integers $n$ and $k$ the size of the permutation and the length of the longest increasing subsequence ($1 \leq k \leq n \leq 10^5$). The second line contains $k$ integers $i_1, \ldots, i_k$ the longest increasing subsequence ($1 \leq i_1 < \ldots < i_k \leq n$). ###Output: If there is no permutation with the sequence $i_1, \ldots, i_k$ being the only longest increasing subsequence, print `NO` . Otherwise, print `YES` on the first line, followed by $n$ numbers describing any suitable permutation on the second line. ###Constraints  $1 \leq T \leq 10$  $1 \leq k \leq n \leq 10^5$  $1 \leq i_1 < \ldots < i_k \leq n$ ###Sample Input: ``` 2 3 2 1 2 2 1 1 ``` ###Sample Output: ``` YES 2 3 1 NO ```Author:  vijju123 
Tags  vijju123 
Date Added:  17112018 
Time Limit:  2 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 