
线段树
文章平均质量分 77
nuaalida
这个作者很懒,什么都没留下…
展开
-
poj 1177 线段树
这题看了好久,先看了陈宏的论文,然后关于测度,连续段数的地方没看明白,后来又找了源代码看,确实自己很难写出来比较简洁的代码,对核心部分还是不够理解。题解:首先离散化,没的说,然后建线段树,要先unique一下y数组,然后根据扫描线,insert,或者remove,并对维护过的点update_m,update_line。最精髓的部分或许是在论文里没有着重提到的如何计算轮廓线,其实只需一次扫描原创 2013-08-09 12:56:16 · 556 阅读 · 0 评论 -
HDOJ 4578 线段树
关键问题是要同时维护每个节点的三个值,sum【1】一次方,sum【2】二次方,sum【3】三次方,还有个update()维护每次的sum值的改变。然后有个lazy【】标记,既然有lazy标记,就要有pushdown的维护。三种操作,+c,*c,=c,显然=c优先级最高,然后是*c,最后是+c,维护每个节点扣留的操作,需要按照这种顺序。可是写出来wa了4遍。对线段树的理解还是不够透彻。原创 2013-08-13 12:54:56 · 662 阅读 · 1 评论 -
线段树 LA3938
又卡住了,写了前面一半,后面一半想不明白了。。#include #include #include #include using namespace std;#define N 1000005struct ans{ int x,y; ans(int x1=0,y1=0):x(x1),y(y1){}};struct node { int L,R;原创 2013-10-03 01:13:07 · 774 阅读 · 0 评论 -
线段树UVa11992
要建多个线段树,有两个基本操作,set和add,优先级上,set比add高,注意关系;query里还是要用到pushdown,有pushdown的地方就一定要有maintain,两者有依存关系;但是pushdown之后,在哪里,在什么位置maintain,不太明白;写完了,好多错误,,maintain对于子节点和中间节点是有区别的,,query是需要pushdown的;即便如此还是原创 2013-10-04 01:52:47 · 517 阅读 · 0 评论 -
(考前水题)UVa 12299 线段树
#include #include #include #include using namespace std;#define N 400000+5#define inf 100000+5struct node { int L,R; int Min;}st[N];int a[N];void build_tree(int p,int l,int r){原创 2013-10-31 21:12:18 · 608 阅读 · 0 评论