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 ...
随机推荐
- opencv中的图像矩(空间矩,中心矩,归一化中心矩,Hu矩)
严格来讲矩是概率与统计中的一个概念,是随机变量的一种数字特征.设 x 为随机变量,C为常数,则量E[(x−c)^k]称为X关于C点的k阶矩.比较重要的两种情况如下: 1.c=0,这时a_k=E(X^k ...
- 安装vue-devools
https://blog.csdn.net/weixin_38654336/article/details/80790698
- ajax 携带参数传递 页面 查找
不从新定义只能传过来数字 ,不能穿字符串 完整的ajax 获取参数跳转页面
- 洛谷题解 P1292 【倒酒】
原题传送门 题目描述 Winy是一家酒吧的老板,他的酒吧提供两种体积的啤酒,a ml和b ml,分别使用容积为a ml和b ml的酒杯来装载. 酒吧的生意并不好.Winy发现酒鬼们都非常穷.有时,他们 ...
- matlab仿真随机数的产生
概率论和数理统计实验(matlab中实现) 一.伯努利分布 R=binornd(N,P); //N,P为二次分布的俩个参数,返回服从参数为N,P的二项分布的随机数,且N,P,R的形式相同. R=bin ...
- Centos 7 firewall的防火墙的规则
这是官方文档: http://www.firewalld.org/documentation/man-pages/firewall-cmd.html 想使用iptables的规则,firewall也可 ...
- MacOs使用CleanMyMac X清除可清除空间
写在前面 本文介绍如何使用CleanMyMac X清除可清除的空间 可以看到,可清除的空间达到了125.79GB,虽然说不影响系统的使用,但是在使用时间机器进行备份的时候,仍然会将可清除空间当成备份的 ...
- dubbo的使用
dubbo现在用的也不多,基本都在用spring cloud那一套,所以不详细写这个dubbo了. 1.zookeeper的安装 2.demo示例 我们需要把提供者注册到dubbo注册中心,消费者去订 ...
- AGC001 E - BBQ Hard [组合数]
这题就是要求 \(\sum_{i=1}^{n} \sum_{j=i+1}^{n} C(a_i+a_j+b_i+b_j,a_i+a_j)\) 考虑搞一搞,\(C(a_i+a_j+b_i+b_j,a_i+ ...
- centos7 下 安装GeoIP2,在nginx中根据ip地址对应的国家转发请求
最近有个需求是根据用户的地理位置,访问不同的服务器,比如国外用户访问国外的服务器,国内的用户访问国内的服务器,实现的思路主要两种: 智能dns,这个需要在阿里云中注册为企业版才有提供 nginx中使用 ...