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;
}


posted @ 2013-10-19 11:27  xlc2845  阅读(142)  评论(0)    收藏  举报