![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
线段树
文章平均质量分 83
xiaoyu1_1
学生
展开
-
POJ 3468 A Simple Problem with Integers----线段树
第一次写线段树啊,当模板用的以后。。。 #include using namespace std; struct node{ node *pleft,*pright; int L,R; long long lnc; long long nsum; }; node tree[1000000]; int ncount=0; int mid(node *p) { retu原创 2013-07-28 10:51:59 · 506 阅读 · 0 评论 -
Codeforces Round #292 (Div. 1) C. Drazil and Park 线段树维护
题意:圆上,询问任意一段弧中,任意两点的距离+两点的权值和的最大值。 先将圆展开,1,2,……n,1,2,……,n,变为段 线段树中,每段记录 1. 当前段最大值, 2. 段中的任意点到段左端点的 权值 最大值 3. 段中的任意点到段右端点的 权值 最大值 更新询问即可。 // 刚开始记录 到段左右端点的最大值的下标,,bug没调出来,干脆换种记录方式写,就过原创 2015-02-27 09:38:05 · 959 阅读 · 0 评论 -
buaa2014校赛 1088 再也不会依赖任何人了----线段树
Description "任何人都不相信未来,任何人也都无法接受未来。 既然这样,那么我再也不会依赖任何人了,也没必要让任何人理解。" "所有的魔女,都由我一人来解决!" homura默言。 现在有一个数字序列,要对这个序列进行实时修改与询问。 ·修改是把一段区间内所有数字都平方。 ·询问是询问一段区间内数字和的平方。 但是询问的结果会非常非常大,所以只需要这个数对61取原创 2014-12-23 15:11:36 · 509 阅读 · 0 评论 -
4578 Transformation 线段树
1A,裸地线段树 题的链接:http://acm.hdu.edu.cn/showproblem.php?pid=4578 #include #include #include #include #include using namespace std; #define N 100010 const int mod=10007; struct node { int l,r,lazy;原创 2014-10-22 12:50:47 · 397 阅读 · 0 评论 -
BestCoder Round #18 1004 &&hdu 5107 K-short Problem 线段树
题解: 1004 K-short Problem 一个线段树问题,将坐标离散化,将建筑和询问放在一起离线排序,先排x,再排y,再先排建筑。按y轴建线段树,因为询问最多第10矮,只要将每一个坐标按大小顺序存10个节点即可,每读到一个建筑,将其插入当前y坐标。询问则询问[-inf,y]的区间里低k小的高度。 写完心好累原创 2014-11-20 16:08:09 · 457 阅读 · 0 评论 -
hdu 4973 A simple simulation problem.---线段树
线段树 点值存 每个种类的个数,原创 2014-09-04 23:13:07 · 596 阅读 · 0 评论 -
hdu 4913 Least common multiple 线段树
点值代表包含改点 且 lcm等于改点原创 2014-08-07 09:21:07 · 866 阅读 · 0 评论 -
hdu-1255-覆盖的面积 线段树
和 hdu 1542差不多 http://blog.csdn.net/u010489389/article/details/19359569 #include #include #include #include using namespace std; #define N 2100 double x1,Y1,x2,y2; struct node { double len,le原创 2014-02-18 10:33:34 · 491 阅读 · 0 评论 -
hdu-1542-Atlantis 线段树
http://xuyemin520.is-programmer.com/posts/25988 http://hi.baidu.com/nicker2010/item/d88fe842c22163a160d7b9ee #include #include #include #include using namespace std; #define N 110 double x1,Y1,x2原创 2014-02-17 22:28:19 · 544 阅读 · 0 评论 -
hdu 4339 Query ---线段树
给两个字符串, 1操作修改其中一个串的一个字符的值 2操作询问从 该字符串开始往后的 两个字符串 字符相同的长度 标记 字符相同为1,不同为0,每次修改相当于修改0,1值, zhi,标记每段的左值 ,为0,或1 la,标记每段从左开始连续1的长度 flag,标记叶子节点的1,0值//没啥用,可删掉。。 len ,标记段长 然后就是更新 ,询问操作了。。 #原创 2014-03-04 16:54:16 · 411 阅读 · 0 评论 -
fzu 2105 Digits Count 线段树
http://blog.csdn.net/hncu1106401/article/details/9796005 因为每个数 和 更新后的数的范围 为0--15,范围非常小,所以就存在很多相邻的并且相同的数 如一段序列 6 6 6 6 6 7 7 7 7 1 1 1 2 2 2 2 2 ,我们可以对相邻并相同的数分为一组,进行懒标记,就能节省时间了。。 #include #includ原创 2014-02-20 16:00:42 · 833 阅读 · 0 评论 -
hdu-3308-LCIS 线段树
结构里 a 该段最左的数 b该段最有的数 la该段从左开始 向右的最长递增长度 lb该段从右开始 向左的最长递增长度 ll该段的 最长递增长度 len该段的总长度 l 该段左端点 r 该段右端点 然后画图思考下,怎么递归着建树和更新,求区间最大值。。。 #include #include #include #include using namespace std; #d原创 2014-02-17 19:31:17 · 472 阅读 · 0 评论 -
hdu-1394- Minimum Inversion Number--- 线段树优化
http://blog.csdn.net/wiking__acm/article/details/7920429 #include #include #include #include #include using namespace std; struct node { int l,r,nsum; }tree[50000]; void build(int id,int原创 2014-02-16 17:19:17 · 440 阅读 · 0 评论 -
hdu-4217-Data Structure? 线段树
先建树, val只有根节点存数的值。 nsum表示该子树还剩多少个数; del(1,x); 要从树中删掉第x个数,,先看跟的左子树的nsum,, 如果x 否则,在右子树中删掉第x-nsum个数。 #include #include #include #include using namespace std; #define N 270000 #define ll __int64 s原创 2014-02-17 09:56:36 · 525 阅读 · 0 评论 -
hdu 3397 Sequence operation 线段树
一看思路就比较清晰的线段树 5个操作,3个修改区间,2个询问 flag值 -1 , 1 , 0 -1表示,左孩子和右孩子的值不等 1 表示,左孩子和右孩子的值都等于1 0表示,左孩子和右孩子的值都等于0 这样就可以用flag值 进行 懒标记了,更新到 段。。 #include #include #include #include #include using namespace st原创 2014-02-20 23:12:34 · 520 阅读 · 0 评论 -
Codeforces 580E Kefa and Watch 线段树
参考:http://blog.csdn.net/w703710691d/article/details/48687603 代码: #include #include #include #include #include #include #include #include using namespace std; #define ll long long const ll mod1 =原创 2015-09-25 18:50:30 · 745 阅读 · 0 评论