链接: https://code forces.ml/contest/1315/problem/c
You are given a sequenceb1,b2,bnb1,b2,bn.findthelexicographicallyminimalpermutationa 1,a2,a2na1,
输入
eachtestcontainsoneormoretestcases.thefirstlinecontainsthenumberoftestcasestt (1t1001t100 )。
thefirstlineofeachtestcaseconsistsofoneintegernn—thenumberofelementsinthesequencebb (1n1001n100 )。
thesecondlineofeachtestcaseconsistsofndifferentintegersb 1,bnb1,bn—elementsofthesequencebb (1bi2 n1bibi )
itisguaranteedthatthesumofnbyalltestcasesdoesn ' t exceed 100100。
Output
For each test case,ifthereisnoappropriatepermutation,print one number11。
Otherwise,print2n2nintegersa1,a2na1,a2n—requiredlexicographicallyminimalpermutationofnumbersfrom 11 to 2n。
Example
输入
复印
51124 134 1 342 3 4 551 5 7 2 8 output
复印
1 2 -14 5 1 2 3 6 -11 3 5 6 7 9 2 4 8 10代码:
# include bits/stdc.husingnamespacestd; long long n,t,r,q,k,s,max1=0,p; 龙龙b[10001]、b[10001]; 地图龙龙,龙龙; int main () ) {cint; wile(t----) {cinn; m.clear (; for(intI=1; i=n; I ) {cinb[i]; mlydqc[i]]=1; (}int flag=1; for(intI=1; i=n; I ) a(I*2-1)=b ) I ); k=b[i]; while(m[k]==1) {k; (if ) k=2*n ) {a[i*2]=k; m[k]=1; }else{flag=0; 黑; }if(flag==0) {cout-1endl; (else ) for ) intI=1; i=2*n; I ) {couta[i] '; }coutendl; } }