1 #include2 #include 3 #define MAXN 8010 4 int tree[MAXN<<2],color[MAXN],ans[MAXN]; 5 inline void PushDown(int rt) 6 { 7 if(tree[rt]!=-1) 8 { 9 tree[rt<<1]=tree[rt<<1|1]=tree[rt];10 tree[rt]=-1;11 }12 }13 void Update(int x,int y,int val,int L,int R,int rt)14 {15 if(x<=L&&R<=y)16 tree[rt]=val;17 else18 {19 int mid=(L+R)>>1;20 PushDown(rt);21 if(mid>=x)22 Update(x,y,val,L,mid,rt<<1);23 if(y>mid)24 Update(x,y,val,mid+1,R,rt<<1|1);25 }26 }27 void Query(int L,int R,int rt)28 {29 if(tree[rt]!=-1)30 {31 for(int i=L;i<=R;i++)32 color[i]=tree[rt];33 }34 else if(L!=R)35 {36 int mid=(L+R)>>1;37 Query(L,mid,rt<<1);38 Query(mid+1,R,rt<<1|1);39 }40 }41 int main()42 {43 int n,x,y,val,i,j;44 while(~scanf("%d",&n))45 {46 memset(tree,-1,sizeof(tree));47 memset(color,-1,sizeof(color));48 memset(ans,0,sizeof(ans));49 while(n--)50 {51 scanf("%d%d%d",&x,&y,&val);52 if(x