#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. P2094运输

    -------------------- 链接:Miku ------------------- 这是一道水贪心,很容易想到做法就是把最贵的两个放在一块,让后当成一个重新放回队列 ---------- ...

  2. opencv —— HoughCircles 霍夫圆变换原理及圆检测

    霍夫圆变换原理 霍夫圆变换的基本原理与霍夫线变换(https://www.cnblogs.com/bjxqmy/p/12331656.html)大体类似. 对直线来说,一条直线能由极径极角(r,θ)表 ...

  3. window10 cmd 常见命令

    AT 计划在计算机上运行的命令和程序. ATTRIB 显示或更改文件属性. BREAK 设置或清除扩展式 CTRL+C 检查. CACLS 显示或修改文件的访问控制列表(ACLs). CALL 从另一 ...

  4. java 和js 时间 格式化(yyyy-MM-dd HH:mm:ss) 以及获取当前时间

    1.js var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); //获取完整的年份(4位,1970 ...

  5. css字体样式+文本样式

    font-family属性值:具体字体名或者字体集 如果是中文或者有单词之间有空格,需要加双引号 字体集: Serif (有装饰线) Sans-serif (无装饰线) Monospace Cursi ...

  6. 吴裕雄--天生自然HADOOP操作实验学习笔记:hbase学生选课案例

    实验目的 复习hbase的shell操作和javaAPI操作 了解javaWeb项目的MVC设计 学会dao(数据库访问对象)和service层的代码编写规范 学会设计hbase表格 实验原理 前面我 ...

  7. C#中调用Windows系统服务exe程序的工具类与重启服务的流程

    场景 使用C#编写的Windows服务程序,在Winform中进行调用. 常用工具类方法检测服务是否存在或者安装,获取服务状态,启动服务,停止服务的方法. 以在Winform中重启服务为例. 注: 博 ...

  8. C# interact with Command prompt

    using System.IO; using System.Diagnostics; static void Main(string[] args) { CmdDemo("dir" ...

  9. 【pattern】设计模式(1) - 单例模式

    前言 好久没写博客,强迫自己写一篇.只是总结一下自己学习的单例模式. 说明 单例模式的定义,摘自baike: 单例模式最初的定义出现于<设计模式>(艾迪生维斯理, 1994):“保证一个类 ...

  10. tp5使用PHPexcel扩展导出excel表

    1,使用composer安装phpexcel包: composer require phpoffice/phpexcel 2,在控制器中创建方法: (1)使用PHPexcel扩展.代码如下 /** * ...