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 ...
随机推荐
- 【Java】实验代码整理(多线程、自定义异常、界面)
1.界面+文件输入输出流 package finalExam; import java.awt.BorderLayout; import java.awt.Container; import java ...
- Java设计模式之Iterator
public interface Aggregate { //调用iterator方法生成实现Iterator接口的类的实例 public abstract Iterator iterator(); ...
- 剑指offer-面试题57_1-和为s的两个数字-双指针
/* 题目: 输入一个递增数组和一个s,求和等于s的两个数组中的数字. */ /* 思路: 双指针问题. */ #include<iostream> #include<cstring ...
- P1478 陶陶摘苹果(升级版)(sort(),时间优化,priority_queue)
题目描述 又是一年秋季时,陶陶家的苹果树结了 n 个果子.陶陶又跑去摘苹果,这次他有一个 a 公分的椅子.当他手够不着时,他会站到椅子上再试试. 这次与 NOIp2005 普及组第一题不同的是:陶陶之 ...
- JAVA控制流程
Java代码有三种执行结构流程,顺序结构.分支结构.循环结构 顺序结构 顺序结构是最简单的代码执行结构,从代码开始逐步执行每一句代码到结束 public class C { public static ...
- 有意思的GitHub项目
1.强大而又优雅的运维一键自动化管理工具,朋友公司在做,大牛支持,墙裂推荐 官方网站:http://www.bigops.com/ 2.用 PHP 写一个命令行音乐搜索下载器,支持 QQ.网易.酷狗. ...
- Uva1660 (点联通度、边联通度问题)
题意: 给定一个n(n<=50)的无向图,问最小删去几个点,可以使得这个图不连通 解法: 1. 基本概念 (1)一个具有 N 个顶点的图,在去掉任意 K-1 个顶点后 (1<=K&l ...
- Uva1639(概率期望/对数处理避免丢失精度)
Uva1639 题意: 有两个盒子各有n个糖果(n<=200000),每天随机选择一个:选第一个盒子的概率是p(0 ≤ p ≤ 1),第二个盒子的概率为1-p,然后吃掉其中的一颗.直到有一天,随 ...
- 树莓派pip安装opencv报错,Could not find a version that satisfies the requirement cv2 (from versions: )No matching distribution found for cv2
前言 我在使用pip install opencv-python 时报错 Could not find a version that satisfies the requirement opencv ...
- Spark学习之路 (二十)SparkSQL的元数据[转]
概述 SparkSQL 的元数据的状态有两种: 1.in_memory,用完了元数据也就丢了 2.hive , 通过hive去保存的,也就是说,hive的元数据存在哪儿,它的元数据也就存在哪儿. 换句 ...