//Accepted    804 KB    40 ms
 //整个题,都是坑
 //1.The first line of each data set contains exactly one integer n,
 //1 <= n <= 8000, equal to the number of colored segments
 //意思是:n表示染色线段的条数,而不是区间的总长度
 //2.x1 and x2 indicate the left endpoint and right endpoint of the segment, c indicates the color of the segment.
 //x1 ,x2 表示染色区间的端点位置,而染色的是区间
 #include <cstdio>
 #include <cstring>
 #include <iostream>
 #include <queue>
 #include <cmath>
 #include <algorithm>
 using namespace std;
 /**
   * This is a documentation comment block
   * 如果有一天你坚持不下去了,就想想你为什么走到这儿!
   * @authr songt
   */
 ;
 int color[imax_n];
 struct node
 {
     int l,r;
     int c;
     int change;
 }f[imax_n*];
 void build(int t,int l,int r)
 {
     f[t].l=l;
     f[t].r=r;
     f[t].c=;
     f[t].change=;
     if (l==r)
     {
         return ;
     }
     ;
     build(*t,l,mid);
     build(*t+,mid+,r);
 }
 void update(int t,int l,int r,int c)
 {
     if (f[t].l==l && f[t].r==r)
     {
         f[t].c=c;
         f[t].change=;
         return ;
     }
     )
     {
         f[*t].c=f[t].c;
         f[*t+].c=f[t].c;
         f[*t].change=f[*t+].change=;
         f[t].change=;
     }
     ;
     *t,l,r,c);
     else
     {
         *t+,l,r,c);
         else
         {
             update(*t,l,mid,c);
             update(*t+,mid+,r,c);
         }
     }
 }
 int query(int t,int k)
 {
     ;
     if (f[t].l==f[t].r && f[t].l==k)
     {
         return f[t].c;
     }
     )
     {
         return f[t].c;
     }
     ;
     *t,k);
     *t+,k);
 }
 int n;
 int x,y,c;
 void slove()
 {
     build(,,);
     ;i<=n;i++)
     {
         scanf("%d%d%d",&x,&y,&c);
         x++;
         c++;
         if (x>y) continue ;
         update(,x,y,c);
     }
     int t1,t2;
     t1=;
     memset(color,,sizeof(color));
     ;i<=;i++)
     {
         t2=query(,i);
         )
         {
             t1=t2;
             continue ;
         }
         if (t2==t1) continue;
         color[t2]++;
         t1=t2;
     }
     ;i<=;i++)
     )
     {
         printf(,color[i]);
     }
 }
 int main()
 {
     while (scanf("%d",&n)!=EOF)
     {
         slove();
         printf("\n");
     }
     ;
 }

zoj1610 线段树的更多相关文章

  1. zoj-1610线段树刷题

    title: zoj-1610线段树刷题 date: 2018-10-16 16:49:47 tags: acm 刷题 categories: ACM-线段树 概述 这道题是一道简单的线段树区间染色问 ...

  2. ZOJ-1610 线段树+两种查询方法(弥补我线段树区间填充的短板)

    ZOJ-1610 线段树+两种查询方法(弥补我线段树区间填充的短板) 题意 题意:给一个n,代表n次操作,接下来每次操作表示把[l,r]区间的线段涂成k的颜色其中,l,r,k的范围都是0到8000 这 ...

  3. zoj1610线段树区间覆盖

    链接https://vjudge.net/contest/66989#problem/F 坑爹的线段树,一直用区间更新做,做了半天一点眉目都没有,只好搜题解,感觉好堕落,经常不会做就搜题解,以后一定要 ...

  4. [ZOJ1610]Count the Colors(线段树,区间染色,单点查询)

    题目链接:http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=1610 题意:给一个长8000的绳子,向上染色.一共有n段被染色,问染 ...

  5. zoj1610(线段树)

    题目连接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1610 题意:在0-8000长的线段里面,按先后次序依次覆盖颜色, ...

  6. kuangbin专题七 ZOJ1610 Count the Colors (灵活线段树)

    Painting some colored segments on a line, some previously painted segments may be covered by some th ...

  7. 线段树专题—ZOJ1610 Count the Colors

    题意:给一个n,代表n次操作,接下来每次操作表示把[l.r]区间的线段涂成k的颜色当中,l,r,k的范围都是0到8000 分析:事实上就是拿线段树维护一段区间的颜色,整体用到的是线段树的区间更新把,可 ...

  8. 【ACM/ICPC2013】线段树题目集合(一)

    前言:前一段时间在网上找了一个线段树题目列表,我顺着做了一些,今天我把做过的整理一下.感觉自己对线段树了解的还不是很深,自己的算法能力还要加强.光练代码能力还是不够的,要多思考.向队友学习,向大牛学习 ...

  9. bzoj3932--可持久化线段树

    题目大意: 最近实验室正在为其管理的超级计算机编制一套任务管理系统,而你被安排完成其中的查询部分.超级计算机中的 任务用三元组(Si,Ei,Pi)描述,(Si,Ei,Pi)表示任务从第Si秒开始,在第 ...

随机推荐

  1. appium支持中文输入

    Appium 1.3.3以上.java:capabilities增加下面两项:capabilities.setCapability("unicodeKeyboard", " ...

  2. java 集合(ArrayList)

    ArrayList: ------------|Collection 单列集合的跟接口 ----------------------|List  有序,可重复. ------------------- ...

  3. Unity4.3 遮挡剔除:基本知识

    http://blogs.unity3d.com/2013/12/02/occlusion-culling-in-unity-4-3-the-basics/ 这篇博文由Umbra Software的J ...

  4. Working with Data » Getting started with ASP.NET Core and Entity Framework Core using Visual Studio » 增、查、改、删操作

    Create, Read, Update, and Delete operations¶ 5 of 5 people found this helpful By Tom Dykstra The Con ...

  5. SpringMVC--xxx.xml配置

    <!--configure the setting of springmvcDispatcherServlet and configure the mapping--> <servl ...

  6. javaScript定义对象的方法

    转自souhu新闻http://news.sohu.com/20110215/n279335637.shtml? javascript定义对象的几种简单方法 1.构造函数方式,全部属性及对象的方法都放 ...

  7. 修复iPhone的safari浏览器上submit按钮圆角bug

    今天在公司写了一个登录页面效果,让我碰到一个怪异的问题——"表单中的input type=submit和input type=reset按钮在iPhone的safari浏览器下圆角有一个bu ...

  8. python 练习 23

    python 编程中 while 语句用于循环执行程序,即在某条件下,循环执行某段程序,以处理需要重复处理的相同任务.其基本形式为: while 判断条件: 执行语句…… 执行语句可以是单个语句或语句 ...

  9. Windows下安装并设置Redis

    Redis对于Linux是官方支持的,安装和使用没有什么好说的,普通使用按照官方指导,5分钟以内就能搞定.详情请参考: http://redis.io/download 但有时候又想在windows下 ...

  10. fill_parent和wrap_content的区别

    在Android布局文件中定义视图垂直或水平大小: android:layout_width和android_layout_height的属性有fill_parent.wrap_content和mat ...