#include<bits/stdc++.h>
using namespace std;
int shu[];
int ans[];
int main() {
int total;
cin>>total;
while(total--) {
int n;
bool flag=true;
cin>>n;
unordered_set<int>tree;
set<int>num;
for(int i=; i<=n; i++) num.insert(i);//插入每个数字 从小到大
for(int i=; i<=n; i++) cin>>shu[i];//记录每个数字
for(int i=; i<=n; i++) {
if(tree.find(shu[i])==tree.end()) {//如果当前位置的最大值没有出现过,那么该最大值在此位置第一次出现
tree.insert(shu[i]);//插入
num.erase(shu[i]);//删除
ans[i]=shu[i];//记录
} else//如果当前位置的最大值出现过 ,就从小于该最大值的数字中随便选一个没用的
{
for(auto j=num.begin(); j!=num.end(); j++) {
if((*j)<shu[i])// 如果有
{
ans[i]=(*j);//加进去
num.erase(j);//删掉
break;//推出循环
} else if(*j>shu[i]) {//如果最小的都大于,
flag=false;
break;
}
}
if(!flag) break;
}
}
if(!flag) cout<<-<<endl;
else {
for(int i=; i<=n; i++) {
cout<<ans[i]<<" ";
}
cout<<endl;
} }
return ;
}

Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) B Box的更多相关文章

  1. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3

    A,有多个线段,求一条最短的线段长度,能过覆盖到所又线段,例如(2,4)和(5,6) 那么我们需要4 5连起来,长度为1,例如(2,10)(3,11),用(3,10) 思路:我们想一下如果题目说的是最 ...

  2. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) F2. Wrong Answer on test 233 (Hard Version) dp 数学

    F2. Wrong Answer on test 233 (Hard Version) Your program fails again. This time it gets "Wrong ...

  3. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) E. Arson In Berland Forest 二分 前缀和

    E. Arson In Berland Forest The Berland Forest can be represented as an infinite cell plane. Every ce ...

  4. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) D2. Optimal Subsequences (Hard Version) 数据结构 贪心

    D2. Optimal Subsequences (Hard Version) This is the harder version of the problem. In this version, ...

  5. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) C. Messy 构造

    C. Messy You are fed up with your messy room, so you decided to clean it up. Your room is a bracket ...

  6. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) B. Box 贪心

    B. Box Permutation p is a sequence of integers p=[p1,p2,-,pn], consisting of n distinct (unique) pos ...

  7. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) A. Math Problem 水题

    A. Math Problem Your math teacher gave you the following problem: There are n segments on the x-axis ...

  8. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) C Messy

    //因为可以反转n次 所以可以得到任何可以构成的序列 #include<iostream> #include<string> #include<vector> us ...

  9. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) A Math Problem

    //只要从所有区间右端点的最小值覆盖到所有区间左端点的最大值即可 #include<iostream> using namespace std ; int x,y; int n; int ...

随机推荐

  1. 快速建立使用django_rest_framework

    快速建立使用django_rest_framework 测试API 其实djangorestframework就是进行增删改查 前往要注意的是 POST的接口的的URL一定要写完整 包括最后的 `/` ...

  2. PHP-CMS代码审计(4)

    这次找了个发卡平台,url:  https://files.cnblogs.com/files/b1gstar/kamiphp.zip 从52破解上下载的 : 先把网站搭建起来. 网站没有采用mvc框 ...

  3. C语言 运算符

    C语言 运算符 运算符优先级别 优先级 运算符 名称或含义 使用形式 结合方向 说明 1 [] 数组下标 数组名[常量表达式] 左到右 -- () 圆括号 (表达式)/函数名(形参表) -- . 成员 ...

  4. 信号处理之DFT、IDFT

    一.DFT之前言部分 由于matlab已提供了内部函数来计算DFT.IDFT,我们只需要会调用fft.ifft函数就行: 二.函数说明: fft(x):计算N点的DFT.N是序列x的长度,即N=len ...

  5. 《茶余饭后小故事》MV*、MVC、MVP、MVVM的前世今生

    今天我们讲讲历史,讲讲故事,不扯高深术语. MV*表示的意思是:M(Model逻辑层) + View(视图层) + *(中间者).上帝提出了这个逻辑与视图分离,用中间者进行连接的伟大思想,并将实现这个 ...

  6. [Linux] git add时的注意事项

    git add -A  提交所有变化 git add -u  提交被修改(modified)和被删除(deleted)文件,不包括新文件(new) git add .  提交新文件(new)和被修改( ...

  7. IDEA 在debug模式下启动慢或者无法启动解决

    参考:https://www.cnblogs.com/han-1034683568/p/8603588.html 背景 这两天在开发项目的时候发现用debug模式启动项目的时候,项目启动速度非常慢甚至 ...

  8. mysql 数据库优化的几种方法

    1.选取最适用的字段属性 MySQL可以很好的支持大数据量的存取,但是一般说来,数据库中的表越小,在它上面执行的查询也就会越快.因此,在创建表的时候,为了获得更好的性能,我们可以将表中字段的宽度设得尽 ...

  9. codeforces 99999/553 Sultan's Pearls Solution 珍珠 题解

    文章目录 珍珠 题意 分析 增加限定条件 去掉限定条件 Code 珍珠 题意 一共n课珍珠,m颗悬挂,其余在桌子上.如图所示. 仆人每天从某一端"借"一颗珍珠珠.主人每天都会检查悬 ...

  10. 牛客练习赛53-E 老瞎眼 pk 小鲜肉

    Problem 这题的题意大概是 给出一段长度为\(n\) 的区间 \(q\)次询问求 \(L\)~ \(R\) 这个区间内 最短的一段区间 \(l\)~\(r\) 使得 \(\oplus_{i=l} ...