zoj1610 线段树
//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 线段树的更多相关文章
- zoj-1610线段树刷题
title: zoj-1610线段树刷题 date: 2018-10-16 16:49:47 tags: acm 刷题 categories: ACM-线段树 概述 这道题是一道简单的线段树区间染色问 ...
- ZOJ-1610 线段树+两种查询方法(弥补我线段树区间填充的短板)
ZOJ-1610 线段树+两种查询方法(弥补我线段树区间填充的短板) 题意 题意:给一个n,代表n次操作,接下来每次操作表示把[l,r]区间的线段涂成k的颜色其中,l,r,k的范围都是0到8000 这 ...
- zoj1610线段树区间覆盖
链接https://vjudge.net/contest/66989#problem/F 坑爹的线段树,一直用区间更新做,做了半天一点眉目都没有,只好搜题解,感觉好堕落,经常不会做就搜题解,以后一定要 ...
- [ZOJ1610]Count the Colors(线段树,区间染色,单点查询)
题目链接:http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=1610 题意:给一个长8000的绳子,向上染色.一共有n段被染色,问染 ...
- zoj1610(线段树)
题目连接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1610 题意:在0-8000长的线段里面,按先后次序依次覆盖颜色, ...
- kuangbin专题七 ZOJ1610 Count the Colors (灵活线段树)
Painting some colored segments on a line, some previously painted segments may be covered by some th ...
- 线段树专题—ZOJ1610 Count the Colors
题意:给一个n,代表n次操作,接下来每次操作表示把[l.r]区间的线段涂成k的颜色当中,l,r,k的范围都是0到8000 分析:事实上就是拿线段树维护一段区间的颜色,整体用到的是线段树的区间更新把,可 ...
- 【ACM/ICPC2013】线段树题目集合(一)
前言:前一段时间在网上找了一个线段树题目列表,我顺着做了一些,今天我把做过的整理一下.感觉自己对线段树了解的还不是很深,自己的算法能力还要加强.光练代码能力还是不够的,要多思考.向队友学习,向大牛学习 ...
- bzoj3932--可持久化线段树
题目大意: 最近实验室正在为其管理的超级计算机编制一套任务管理系统,而你被安排完成其中的查询部分.超级计算机中的 任务用三元组(Si,Ei,Pi)描述,(Si,Ei,Pi)表示任务从第Si秒开始,在第 ...
随机推荐
- Machine Learning - 第6周(Advice for Applying Machine Learning、Machine Learning System Design)
In Week 6, you will be learning about systematically improving your learning algorithm. The videos f ...
- VB6 GDI+ 入门教程[8] Bitmap魔法(1):创建
http://vistaswx.com/blog/article/category/tutorial/page/2 VB6 GDI+ 入门教程[8] Bitmap魔法(1):创建 2009 年 9 月 ...
- dede调用文章的栏目,作者,发布时间.以及连接数据库输出一个表
发布时间: {dede:field.pubdate function="MyDate('Y-m-d H:i',@me)"/}类目:{dede:field.typename/}发布人 ...
- Unity5中叹为观止的实时GI效果
http://www.manew.com/thread-43970-1-1.html 今天为大家分享unity与Alex Lovett共同使用unity5制作的Shrine Arch-viz Demo ...
- EF Core » 影子属性
Caution:注意 This documentation is for EF Core. For EF6.x and earlier release see http://msdn.com/data ...
- MHA的几种死法-叶良辰
master不通 找到最新slave 找到有所有其他slave缺失relay log的 slave 选主 配置文件指定 ...
- DirectX小记
1.关于SetViewPort 如果不调用SetViewPort,那么设备对应的ViewPort是什么. 2.关于多线程渲染 如果逻辑线程和渲染线程分开, 则存在两种渲染方式 a.逻辑线程一次性提交渲 ...
- Jquery 操作Html 控件 CheckBox、Radio、Select 控件 【转】http://www.cnblogs.com/lxblog/archive/2013/01/09/2853056.html
Jquery 操作Html 控件 CheckBox.Radio.Select 控件 在使用 Javascript 编写前台脚本的时候,经常会操作 Html 控件,比如 checkbox.radio ...
- 51nod 1050 循环数组最大子段和
题目链接:51nod 1050 循环数组最大子段和 #include<stdio.h> #include<algorithm> using namespace std; ; l ...
- hadoop主节点(NameNode)备份策略以及恢复方法
link:http://jiajun.iteye.com/blog/809125 一.dits和fsimage 首先要提到两个文件edits和fsimage,下面来说说他们是做什么的. 集群中的名称节 ...