The region of the Line Segment tree is updated, and then spof queries are performed.
X1 x2 c: Region update x1-x2 is c.
After all the colors are colored, the color of each vertex is queried from 0. Each color is stored in several pieces.
#include
#include
#include
#include#include
using namespace std;#define lmin 0#define rmax 8000#define lson l,(l+r)/2,rt<<1#define rson (l+r)/2+1,r,rt<<1|1#define root lmin,rmax,1#define maxn 10000int cl[maxn*4];int num[maxn];void push_up(int rt){}void push_down(int rt){ if(cl[rt]!=-1) { cl[rt<<1]=cl[rt]; cl[rt<<1|1]=cl[rt]; cl[rt]=-1; }}void update(int ll,int rr,int x,int l,int r,int rt){ if(l>rr||r
=r) { // cout<
st)return 0; if(l==r&&st==l)return cl[rt]; if(l<=st&&r>=st&&cl[rt]!=-1)return cl[rt]; return query(st,lson)+query(st,rson);}int main(){ int n,l,r,c; while(~scanf("%d",&n)) { memset(cl,-1,sizeof(cl)); memset(num,0,sizeof(num)); while(n--) { scanf("%d%d%d",&l,&r,&c); update(l,r-1,c,root); } int y=-1; for(int i=0;i<=8000;i++) { int x=query(i,root); //cout<
=0)num[x]++; } for(int i=0;i<=8000;i++) { if(num[i]) { printf("%d %d\n",i,num[i]); } } cout<