Red Huang

Red Huang

Codeforces 第207轮比赛(Div. 2)骑士锦标赛

利用 stl 来做就可以了,在此发现 algortihm 的 lower_bound 不及 set 的

貌似 set 里面已经有做处理了

/*  
 * GCA : "Computer is artificial subject absolutely,Math is God"  
 */  
#include <iostream>  
#include <cstdio>  
#include <cstring>  
#include <algorithm>  
#include <cmath>  
#include <climits>  
#include <vector>  
#include <set>  
#include <map>  
#include <queue>  
#include <cctype>  
#include <utility>  
#include <ctime>  
using namespace std;  
#ifdef DEBUG  
#define VAR(a,b) __typeof(b) a=(b)  
#define debug(...) printf("DEBUG: "),printf(__VA_ARGS__)  
#else  
#define VAR(a,b) __typeof(b) a=(b)  
#define debug(...)  
#endif  
typedef unsigned int uint;  
typedef long long int Int;  
typedef unsigned long long int UInt;  
#define Set(a,s) memset(a,s,sizeof(a))  
#define Pln() printf("\n")  
#define For(i,x)for(int i=0;i<x;i++)  
#define CON(x,y) x##y  
#define M 300005  
#define PB push_back  
#define oo INT_MAX  
#define FOR(a,b) for(VAR(a,(b).begin());a!=(b).end();++a)  
#define eps 1e-9  
#define X first  
#define Y second  
inline bool xdy(double x,double y){return x>y+eps;}  
inline bool xddy(double x,double y){return x>y-eps;}  
inline bool xcy(double x,double y){return x<y-eps;}  
inline bool xcdy(double x,double y){return x<y+eps;}  
const Int mod=1000000007;  
int ans[M];  
int n,m;  
set<int>::iterator a,b,it;  
set<int> s;  
int main() {  
    ios_base::sync_with_stdio(0);  
    while(~scanf("%d%d",&n,&m)){  
        for(int i=1;i<=n;i++)s.insert(i);  
        while(m--){  
            int l,r,k;  
            scanf("%d%d%d",&l,&r,&k);  
            a=s.lower_bound(l);  
            b=s.upper_bound(r);  
            for(it=a;it!=b;it++){  
                if(!ans[*it]&&*it!=k)ans[*it]=k;  
            }  
            s.erase(a,b);  
            s.insert(k);  
        }  
        for(int i=1;i<=n;i++){  
            printf("%d ",ans[i]);  
        }  
  
    }  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
}  

加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。