线段树
文章平均质量分 84
wJs9528-1
这个作者很懒,什么都没留下…
展开
-
Hdu 3397 Sequence operation 区间合并+区间更新+翻转操作
Sequence operationTime Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescriptionlxhgww got a sequence contains n characters which are all '0's or '1's.We h原创 2015-08-17 10:44:01 · 487 阅读 · 0 评论 -
HDU 5649 DZY Loves Sorting(线段树+二分)
题意:给出一个序列,m次[L,R]区间的原地排序,最后只有一次询问下标为k的值为多少题解:二分求解答案,对于数m,比它大的置为1,比它小的置为0,线段树处理排序过程,复杂度(n+m)∗log2(n)(n+m)*log^2(n)#include<cstring>#include<string>#include<iostream>#include<queue>#include<cstdio>#原创 2016-09-19 21:24:36 · 362 阅读 · 0 评论 -
HDU 4348 SPOJ TTM To the moon(操作建树)
题意:给出一个序列,四种操作C l r d: Adding a constant d for every {Ai | l <= i <= r}, and increase the timestamp by 1, this is the only operation that will cause the timestamp increase. Q l r: Querying the current原创 2016-08-24 14:21:10 · 389 阅读 · 0 评论 -
hdu 5818 Joint Stacks(线段树)
Joint Stacks------------Problem DescriptionA stack is a data structure in which all insertions and deletions of entries are made at one end, called the "top" of the stack. The last entry which is in原创 2016-08-09 18:49:49 · 421 阅读 · 0 评论 -
HDU 5692 Snacks( dfs序 + 线段树处理区间求和)
SnacksTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1241 Accepted Submission(s): 280Problem Description百度科技园内有n个零食机,零食机之间通过n原创 2016-07-08 15:01:37 · 505 阅读 · 0 评论 -
Codeforces Round #200 (Div. 1) Water Tree (dfs序+线段树)
题意:给出一棵树三种操作1.将某点及其子节点灌满水2.将某点及其所有父节点放掉水3.询问某点是否有水分析:乍一看这题,子树似乎可以用dfs序处理,父链似乎可以用树链剖分处理,但是仔细想想树链剖分这里似乎根本用不上,也没法用对于1,2操作,其实是互斥的,对于一个点来说,该点是否有水取决于改点充满水的时间和放掉水的时间,那么其实我们就是在判断该点1,2操作的先后原创 2016-07-28 10:30:05 · 139 阅读 · 0 评论 -
POJ 2155 Matrix (二维线段树)
MatrixTime Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uDescriptionGiven an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th原创 2016-03-01 11:06:26 · 412 阅读 · 0 评论 -
POJ 2777 Count Color (二进制或 线段树)
由于T不超过30,可以用一个数表示当前区间的已有颜色,异或操作来pushup每一个区间#include#include#include#include#include#include#include#include#include#include//#pragma comment(linker, "/STACK:1024000000,1024000000");u原创 2016-02-29 09:10:01 · 565 阅读 · 0 评论 -
HDU 4267 A Simple Problem with Integers (55棵线段树更新维护)
看了大牛的博客才知道怎么做,头回写这么多棵树,好惊悚http://blog.csdn.net/ophunter_lcm/article/details/9455723意思大概是这样,对于 i=a+n*k,根据同余定理可知 i%k = a%k,k最大为10,那么就可以分为 1+2+3+...+10=55种情况,分别是每种k取模后的不同值,建立这55种线段树,每次维护值的时候找到对原创 2016-02-29 22:04:11 · 296 阅读 · 0 评论 -
HDU 1828 Picture (线段树扫描线求周长并 区间合并)
扫描线求每次的上下已有边长,同时区间合并记录边长的分布情况乘以高度差求出高度的变长#include#include#include#include#include#include#include#include#include#include//#pragma comment(linker, "/STACK:1024000000,1024000000");usi原创 2016-02-29 19:15:18 · 461 阅读 · 0 评论 -
HDU 1542 Atlantis (线段树扫描线求面积并)
AtlantisTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uAppoint description:DescriptionThere are several ancient Greek texts that contain descriptions原创 2016-02-29 19:11:21 · 420 阅读 · 0 评论 -
HDU 4614 Vases and Flowers (线段树 + 二分)
Vases and FlowersTime Limit:2000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescription Alice is so popular that she can receive many flowers everyday. She has N vases nu原创 2016-03-02 18:51:26 · 556 阅读 · 0 评论 -
hdu 2795 Billboard (线段树,优先找满足条件的坐标较小的)
BillboardTime Limit:8000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescription在学校的入口处有一个巨大的矩形广告牌,高为h,宽为w。所有种类的广告都可以贴,比如ACM的广告啊,还有餐厅新出了哪些好吃的,等等。。 在9月1号这天,广告牌是空的,之后广告会被原创 2016-02-23 18:26:22 · 389 阅读 · 0 评论 -
hdu 1166 敌兵布阵(线段树,伸展树)
敌兵布阵Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营原创 2016-02-23 16:47:26 · 137 阅读 · 0 评论 -
HDU 4027 Can you answer these queries?
最大的数开根号最多7次到1,每次单点更新,对于全是1的区间标记不用再更新。注意l>r的情况#include#include#include#include#include#include#include#include#include#include//#pragma comment(linker, "/STACK:1024000000,1024000000")原创 2016-03-02 12:54:28 · 309 阅读 · 0 评论 -
HDU 2871 Memory Control 区间合并+区间更新
Memory ControlTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescriptionMemory units are numbered from 1 up to N.A sequence of memory units is called a m原创 2015-08-17 15:36:22 · 440 阅读 · 0 评论 -
POJ 3667 Hotel 区间合并+区间更新
HotelTime Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uDescriptionThe cows are journeying north to Thunder Bay in Canada to gain cultural enrichment and e原创 2015-08-17 10:33:17 · 661 阅读 · 0 评论 -
HDU 4046 Panda (分块 或 线段树区间合并)
题面挺美的 题意:给出一个字符串,两种操作1.询问区间[l,r]内wbw有多少个(可重叠)2.将位置x的字符改为c 题解:分块和线段树都可以搞,分块很好解释,只需要单独处理边界问题。线段树区间合并需要将每次询问的区间拿出来单独处理一次。分块:#include<cstring>#include<string>#include<iostream>#include<queue>#include原创 2016-10-31 22:52:43 · 360 阅读 · 0 评论