//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. 在XP下把win7安装到VHD,内存足够大可以RAMOS

    在XP下把win7安装到VHD,内存足够大可以RAMOS1.用DiskGenius创建VHD固定大小磁盘文件,以win7vhd.vhd为例,然后进行分区格式化,格式化时启用NTFS压缩.2.进入WIN ...

  2. 小韦XP 和win2003装电信天翼3G无线上网卡

    拷贝文件.bat @echo 开始注册echo n|copy /-y msports.dll %windir%\system32\regsvr32 /s %windir%\system32\mspor ...

  3. java 连接msql数据库

    1.首先下载mysql的的java驱动,下载完成后把解压的mysql-connector-java-3.1.14-bin-g.jar文件放到eclipse的java项目下,然后构建路径. 2.java ...

  4. package-info.java文件详解

    欢迎关注我的社交账号: 博客园地址: http://www.cnblogs.com/jiangxinnju/p/4781259.html GitHub地址: https://github.com/ji ...

  5. String的那一大堆事儿--1

    perfTimeStr = perfTimeStr.replace(perfTimeStr.substring(0,4), "____"); perfTimeStr = perfT ...

  6. Link Collecting

    ----------------------------------\ ACM入门总结之常见输入输出格式暨hdu1089~1096 题解,谨献给对acm感兴趣的新人 - 博客频道 - CSDN.NET ...

  7. 006-Selenium简介

    1.产生背景 Selenium工具诞生的时间已经超过了10年,目前已经在软件开发公司中得到大规模的应用.2004年,在ThoughtWorks公司,一个名为Jason Huggins的测试同行为了减少 ...

  8. Merkle Tree学习

    /*最近在看Ethereum,其中一个重要的概念是Merkle Tree,以前从来没有听说过,所以查了些资料,学习了Merkle Tree的知识,因为接触时间不长,对Merkle Tree的理解也不是 ...

  9. CentOS 7.x安装配置

    简述 VMware可以创建多个虚拟机,每个虚拟机上都可以安装各种类型的操作系统.安装方法也有很多种.下面,主要以ISO镜像安装为例,介绍CentOS 7.x的安装过程及相关的参数设置. 简述 创建虚拟 ...

  10. Java 集合系列 03 ArrayList详细介绍(源码解析)和使用示例

    java 集合系列目录: Java 集合系列 01 总体框架 Java 集合系列 02 Collection架构 Java 集合系列 03 ArrayList详细介绍(源码解析)和使用示例 Java ...