读错题意了。。线段树延迟标记
白刷这么多线段树
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
using namespace std;
#define N 300010
int s[N<<],la[N<<];
struct node
{
int l,r,d;
}q[N];
void update(int a,int b,int p,int l,int r,int w)
{
if(a<=l&&b>=r)
{
s[w] = p;
return ;
}
if(s[w])
{
s[w<<] = s[w<<|] = s[w];
s[w] = ;
}
int m = (l+r)>>;
if(a<=m)
update(a,b,p,l,m,w<<);
if(b>m)
update(a,b,p,m+,r,w<<|);
}
int query(int k,int l,int r,int w)
{
if(l==r)
return s[w];
if(s[w])
s[w<<] = s[w<<|] = s[w];
int m = (l+r)>>;
if(k<=m)
return query(k,l,m,w<<);
else
return query(k,m+,r,w<<|);
}
int main()
{
int i,n,m;
int a,b,c;
scanf("%d%d",&n,&m);
for(i = ; i <= m ;i++)
{
scanf("%d%d%d",&q[i].l,&q[i].r,&q[i].d);
}
for(i = m ; i >= ; i--)
{
a = q[i].l;b = q[i].r; c = q[i].d;
if(a!=c)
update(a,c-,c,,n,);
if(b!=c)
update(c+,b,c,,n,);
}
for(i = ; i < n ; i++)
printf("%d ",query(i,,n,));
printf("%d\n",query(n,,n,));
return ;
}