您的位置:首页 > 其它

cf 357C

2013-10-19 11:27 176 查看
比赛的时候纯暴力超时了 看了别人的代码 set容器类做的 stl里还是有很多好东西的

/*************************************************************************
> Author: xlc2845       > Mail: xlc2845@gmail.com
> Created Time: 2013年10月19日 星期六 10时20分33秒
************************************************************************/

#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <vector>
#include <cstdio>

using namespace std;
set<int> t;
set<int>::iterator it1, it2, it;
int w[300010];
int main ( )
{
int n,m,le,re,x;
scanf("%d%d",&n,&m) ;
for(int i = 1; i <= n; i++)
t.insert(i);
while(m--)
{
scanf("%d%d%d", &le, &re, &x);
it1 = t.lower_bound(le);
it2 = t.lower_bound(re + 1);
for (it = it1 ; it != it2; it++)
w[*it] = x;
t.erase(it1, it2);
t.insert(x);
}
w[x] = 0;
for(int i = 1; i <= n; i++)
printf( "%d ", w[i]);
puts("");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: