Codeforces 356A
这题有个注意的地方,就是对集合边读边删除的时候,应该尤为注意。。 my_set.erase(it++)
#include <iostream> #include <cstring>
#include <set> using namespace std; int color[]; int main(){
int n, m;
while (cin >> n >> m) {
set<int> my_set;
for (int i = ; i <= n; i++) {
my_set.insert(i);
}
memset(color, , sizeof(color)); for (int i = ; i < m; i++) {
int l, r, x;
cin >> l >> r >> x;
set<int>::iterator it;
it = my_set.lower_bound(l);
while (it != my_set.end()) {
if ((*it) > r) {
break;
}
if ((*it) == x) {
it++;
continue;
}
color[(*it)] = x;
my_set.erase(it++);
/* it++; */
}
}
for (int i = ; i <= n; i++) {
cout << color[i] << (i==n ? '\n' : ' ');
}
} return ;
}
Codeforces 356A的更多相关文章
- CodeForces - 356A Knight Tournament
http://codeforces.com/problemset/problem/356/A 首先理解题意 每次给出l 和r 在l - r之间还有资格的选手中得出一个胜者 暴力思路: 首先维护还有资 ...
- 【Codeforces 356A】Knight Tournament
[链接] 我是链接,点我呀:) [题意] n个人矩形m场比赛 每场比赛由编号为li~ri且之前没有被淘汰的人进行. 已知第i场的winner是xi winner会把这一场其他所有的人都淘汰. 问你n个 ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
随机推荐
- RedHat服务器搭建Jenkins
- RQNOJ--160 竞赛真理(01背包)
题目http://www.rqnoj.cn/problem/160 分析:这是一个01背包问题,对于每一道题目,都有两个选择"做"或者"不做". 但是唯一不同的 ...
- SW数据库结构列表
数据表列表 PE_Admin:管理员信息表 PE_Advertisement:广告信息表 PE_AdZone:版位信息表 PE_Announce:公告信息表 PE_AreaCollection:采集信 ...
- js (function(){}()),(function(){})(),$(function(){});之间的区别
参考:https://blog.csdn.net/stpice/article/details/80586444 (function(){}()), (function(){})() 均为立即执行函数 ...
- MFC ,List使用
出自http://www.cnblogs.com/yuehui/archive/2012/06/15/2550449.html List容器双向线性表list容器 list类定义了双向的线性表.V ...
- Autoware显示用户界面细节
https://blog.csdn.net/jianxuezixuan/article/details/86015224
- PAT甲级——A1053 Path of Equal Weight
Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti. The weig ...
- 逻辑备份(mysqldump/select into outfile)
#mysqldump备份 shell> mysqldump -uroot -p -P4306 sakila actor>E:\sakila-actor.sql shell> mysq ...
- java中error和exception的区别
转自:https://www.jianshu.com/p/e8bbee3c1c4a Error类和Exception类的父类都是throwable类,他们的区别是: Error类一般是指与虚拟机相关的 ...
- Django项目:CRM(客户关系管理系统)--27--19PerfectCRM实现King_admin数据修改
登陆密码设置参考 http://www.cnblogs.com/ujq3/p/8553784.html {#table_data_list.html#} {## ————————08PerfectCR ...