链接:https://codeforces.ml/contest/1315/problem/C

You are given a sequence b1,b2,…,bnb1,b2,…,bn. Find the lexicographically minimal permutation a1,a2,…,a2na1,a2,…,a2n such that bi=min(a2i−1,a2i)bi=min(a2i−1,a2i), or determine that it is impossible.

Input

Each test contains one or more test cases. The first line contains the number of test cases tt (1≤t≤1001≤t≤100).

The first line of each test case consists of one integer nn — the number of elements in the sequence bb (1≤n≤1001≤n≤100).

The second line of each test case consists of nn different integers b1,…,bnb1,…,bn — elements of the sequence bb (1≤bi≤2n1≤bi≤2n).

It is guaranteed that the sum of nn by all test cases doesn't exceed 100100.

Output

For each test case, if there is no appropriate permutation, print one number −1−1.

Otherwise, print 2n2n integers a1,…,a2na1,…,a2n — required lexicographically minimal permutation of numbers from 11 to 2n2n.

Example

input

Copy

5
1
1
2
4 1
3
4 1 3
4
2 3 4 5
5
1 5 7 2 8

output

Copy

1 2
-1
4 5 1 2 3 6
-1
1 3 5 6 7 9 2 4 8 10

代码:

#include<bits/stdc++.h>
using namespace std;
long long n,t,r,q,k,s,max1=0,p;
long long a[10001],b[10001];
map<long long ,long long>m;
int main()
{cin>>t;while(t--){cin>>n;m.clear();for(int i=1;i<=n;i++){cin>>b[i];m[b[i]]=1;}int flag=1;for(int i=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;break;}}if(flag==0){cout<<-1<<endl;}else{for(int i=1;i<=2*n;i++){cout<<a[i]<<" ";}cout<<endl;}}
}

C. Restoring Permutation相关推荐

  1. Restoring Permutation CodeForces - 1315C(思维)

    You are given a sequence b1,b2,-,bn. Find the lexicographically minimal permutation a1,a2,-,a2n such ...

  2. Codeforces Round #623 (Div. 2, based on VK Cup 2019-2020 - Elimination Round, Engine) C. Restoring

    C. Restoring Permutation time limit per test1 second memory limit per test256 megabytes inputstandar ...

  3. E. Restoring the Permutation

    E. Restoring the Permutation Example input 4 7 3 3 4 4 7 7 7 4 1 2 3 4 7 3 4 5 5 5 7 7 1 1 output 3 ...

  4. Restoring the Permutation CodeForces - 1506E

    题目链接:E. Restoring the Permutation 题解:按字典序最小的简单一点,字典序大的较为复杂,找出字典序最大的可以通过栈,如果当前的a[i]值和a[i-1]值不相等,说明b[i ...

  5. Restoring the Permutation

    cf题目链接 题意简述:原有一序列p,p中元素为[1,n],通过q[i]=max(p[1],p[2]-,p[i])得到一个新的序列q,现给出q,问满足规则的字典序最大和最小的p序列分别是什么 解法:通 ...

  6. 【C++】C++11 STL算法(七):排列操作(Permutation operations)、数值操作(Numeric operations)

    排列操作(Permutation operations) 一.is_permutation 1.原型: template< class ForwardIt1, class ForwardIt2 ...

  7. LeetCode 76. Minimum Window Substring / 567. Permutation in String

    76. Minimum Window Substring 典型Sliding Window的问题,维护一个区间,当区间满足要求则进行比较选择较小的字串,重新修改start位置. 思路虽然不难,但是如何 ...

  8. R语言使用lmPerm包应用于线性模型的置换方法(置换检验、permutation tests)、使用lm模型构建简单线性回归模型、使用lmp函数生成置换检验回归分析模型

    R语言使用lmPerm包应用于线性模型的置换方法(置换检验.permutation tests).使用lm模型构建简单线性回归模型.使用lmp函数生成置换检验回归分析模型(Permutation te ...

  9. R语言使用coin包应用于独立性问题的置换检验(permutation tests、响应变量是否独立于组、两个数值变量是独立的吗、两个分类变量是独立的吗)、以及coin包的常用置换检验函数

    R语言使用coin包应用于独立性问题的置换检验(permutation tests.响应变量是否独立于组.两个数值变量是独立的吗.两个分类变量是独立的吗).以及coin包的常用置换检验函数 目录

最新文章

  1. 【图论专题】Floyd算法及其扩展应用
  2. nginx-URL重写
  3. 实现抢红包算法?如此简单
  4. POJ 2553 The Bottom of a Graph
  5. 【算法导论】第24章迪杰斯特拉算法
  6. 图解设计模式:状态模式
  7. MSM8937的sbl1和CDT
  8. centos ntp日志_centos NTP服务器配置总结
  9. 中国社会为何多犬儒?
  10. html群聊插件,团队群聊.html
  11. 网站流量可视化分析--页面指标分析、访问量分析
  12. 道一云与畅捷通T+对接集成获取报销信息列表=>凭证创建
  13. 日语基础复习 Day 4
  14. 在 阿里云ECS 上安装 CDH6.2 standalong
  15. PEP8中文翻译(转)
  16. 十位安卓开发者的 17 年总结
  17. BZOJ3032 七夕祭 均分纸牌问题的变式 (前缀和+中位数)
  18. 震惊!手把手教你用Python破解邻家小妹wifi密码
  19. vuejs集成simditor
  20. 餐饮供应链管理系统解决方案

热门文章

  1. 脑电EEG代码开源分享 【6. 分类模型-深度学习篇】
  2. 政府对加密数字货币的态度
  3. 简单重力感应跑步测速应用
  4. 逻辑为基、数企赋能(NO.3)-逻辑定律
  5. 计算机毕业设计ssm+vue基本微信小程序的电影票务系统-电影票预订系统
  6. 在v8系统上显示数据库的数据
  7. 本人对于收购事件的评论
  8. win10禁用数字签名
  9. React Conf 2018大会发布React Hooks和React 16.7 Alpha
  10. MySQL切换版本方法