题目链接:http://codeforces.com/contest/355/problem/B
很水的题,直接计算比大小就行,一开是纠结在分析4种票怎么分配了。。。汗~~~~
#include<stdio.h>
#include<stdlib.h>
using namespace std;
#define N 300002
int a[N],b[N],l[N],r[N],x[N];
int main(void)
{
int n,m;
scanf("%d %d",&n,&m);
for(int i=1;i<=n;i++)
{
a[i] = 0;
b[i] = 0;
}
for(int i=1;i<=m;i++)
{
scanf("%d %d %d",&l[i],&r[i],&x[i]);
for(int j=l[i];j<=r[i];j++)
if(!b[j] && j != x[i])
{
a[j] = x[i];
b[j] = 1;
}
}
for(int i=1;i<=n;i++)
printf("%d ",a[i]);
printf("\n");
return 0;
}