Problem J. find hidden array
时间限制 1500 ms
内存限制 256 MB
You are given an integer $N$. There is a hidden array of size $2 \times N$ containing a permutation of $1 \sim 2 \times N$.
There is an empty set. Initially, the first $N$ integers of this array are inserted into the set. Then, there are $N$ operations performed. The $i$-th operation is one of the following two actions:
1. take out the LARGEST number from the set, and then insert the $(i+N)$-th number from the array into the set.
2. take out the SMALLEST number from the set, and then insert the $(i+N)$-th number from the array into the set.
For each operation, you only know which action is taken and what's the number taken out from the set.
Please find out the content of the hidden array based on the given information. If there are many possible such arrays, you must output the lexicographically smallest one.
输入数据
输出数据
For each test, if it's impossible to recover such array, output a single integer $-1$ in a line. Otherwise, output $2 \times N$ positive integers, indicating the array you recovered. If there are multiple ways, you should choose the lexicographically smallest one.
样例输入
复制
4
3
-1 4 -2
1
2
2
-4 3
4
-2 8 6 -3
样例输出
复制
1 2 3 4 5 6
2 1
-1
2 3 4 5 8 6 7 1
$ Mathjax font initiator $