//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. 【转】 Android自定义捕获Application全局异常

    大家都知道,现在安装Android系统的手机版本和设备千差万别,在模拟器上运行良好的程序安装到某款手机上说不定就出现崩溃的现象,开发者个人不可能购买所有设备逐个调试,所以在程序发布出去之后,如果出现了 ...

  2. PC上安装多个操作系统

    目 录 第1章 绪论    1 1.1 目标    1 1.2 适宜的读者    1 第2章 制作启动U盘    2 2.1 初级安装    2 2.2 启动分析    3 2.3 高级安装    1 ...

  3. 【转】 C++中的new VS C语言中的malloc

    作者:gnuhpc 出处:http://www.cnblogs.com/gnuhpc/ 前几天一个朋友去面试百度空间的一个职位,被问及这个问题,我听后说了几点,不过感觉还是不透彻,所以上网查阅了一些资 ...

  4. flasCC技术点记录

    [待测试特性] 一.C接口导出相关 1.重载函数. 2.虚函数. 3.template相关 二.内存相关 1.as直接往c分配的内存写数据. 2.c直接往as对象写数据. 三.C访问AS 1.访问as ...

  5. [Jetty] jetty 内存调优

    在start.ini中配置代码如下 -Dcom.sun.management.jmxremote=true -Xmx6144m -XX:PermSize=256M -XX:MaxPermSize=10 ...

  6. 正确理解Spring AOP中的Around advice

    Spring AOP中,有Before advice和After advice,这两个advice从字面上就可以很容易理解,但是Around advice就有点麻烦了. 乍一看好像是Before ad ...

  7. hdu 4081 Qin Shi Huang's National Road System (次小生成树)

    Qin Shi Huang's National Road System Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/3 ...

  8. poj----(1470)Closest Common Ancestors(LCA)

    Closest Common Ancestors Time Limit: 2000MS   Memory Limit: 10000K Total Submissions: 15446   Accept ...

  9. servlet 配置

    <servlet> <servlet-name>HelloServlet</servlet-name> <servlet-class>com.web.s ...

  10. linux查看是否已安装GCC及安装GCC

    输入:gcc -v;如果提示未找到命令即表示没有安装 使用:yum install gcc即可