cf 357C

比赛的时候纯暴力超时了  看了别人的代码  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;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值