Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) B Box
#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的更多相关文章
- 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) 思路:我们想一下如果题目说的是最 ...
- 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 ...
- 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 ...
- 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, ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) C Messy
//因为可以反转n次 所以可以得到任何可以构成的序列 #include<iostream> #include<string> #include<vector> us ...
- 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 ...
随机推荐
- Docker 网络原理
引言 学习docker网络,可以带着下面两个问题来探讨 容器之间可以相互访问的原理 容器暴露端口后,通过宿主机访问到容器内应用,并且对于访问端而言不用感知容器存在的原理 Docker 本身的技术依赖L ...
- Django2.2 静态文件的上传显示,遇到的坑点-------已解决
前情提要:这里虽说是Django2.2 ,但经过测试发现Django 的其他版本也可以用此方法解决 一.项目根目录下的static文件的路由显示问题 在项目根目录下创建静态文件时发现,即使我配置了se ...
- 185.nvm和node.js环境配置
安装nvm nvm(Node Version Manager)是一个用来管理node版本的工具,我们之所以使用node,是因为我们需要使用node中的npm(Node Package Manager) ...
- Java与Go语言差异1 传值还是传引用
在Java中,复杂类型(除原始类型外的其它类)作为入参,在方法中被修改后,跳出方法对象内的值仍会保持,也就是传的是引用.原始类型传的是值,如int, double等原始类型. Java代码: publ ...
- Electron – 基础学习(2): 项目打包成exe桌面应用 之electron-packager
项目创建完成,启动正常,接下来就是项目打包了.将测试Demo打包成exe桌面应用,点击exe文件,运行项目. 书接上文,创建项目有三种方式 Git拷贝.直接创建:通过electron社群提供的命令行工 ...
- Element节点
Element节点对象对应网页的 HTML 元素.每一个 HTML 元素,在 DOM 树上都会转化成一个Element节点对象(以下简称元素节点).元素节点的nodeType属性都是1.Element ...
- Intel 8086 标志寄存器及JCC指令表
汇编 JCC指令表 JCC指条件跳转指令,CC就是指条件码. JCC指令 中文含义 英文原意 检查符号位 典型C应用 JZ/JE 若为0则跳转:若相等则跳转 jump if zero;jump if ...
- kaggle之猫狗数据集下载
链接:https://pan.baidu.com/s/1l1AnBgkAAEhh0vI5_loWKw 提取码:2xq4 百度网盘实在是恶心,找的别人的网盘下载不仅速度慢,还老挂掉,自己去kaggle下 ...
- 【spring】jdbcTemplate之sql参数注入
demo @Repository("jdbcDao") public class JdbcTemplateDao { @Autowired private JdbcTemplate ...
- Django---Django安装数据库
前面我们介绍了如何通过Django完成数据的接收和数据交互,那么我们都知道,数据一般都是通过数据库存储的,然而我们作为测试肯定和数据库也是经常打交道的,今天就简单的介绍下,如何在windows上安装数 ...