![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
线段树
古古天
如花美眷也敌不过似水流年 心若磐石也敌不过过眼云烟
展开
-
初见线段树
看了一天的线段树了,真心觉得这算法好难,虽然是模板,但每个题目不是给个模板就能AC的吧,看是得慢慢把算法弄懂,我觉得不会码倒在其次,要能在看到题目变动的时候适时改变算法。 //线段树模板 struct line { int left,right;//左端点、右端点 int n;//记录这条线段出现了多少次,默认为0 }; struct line a[100]; int sum;原创 2013-08-25 22:04:27 · 844 阅读 · 0 评论 -
HDOJ1166 敌兵布阵
赤裸裸的线段树,借个模板,改写一下即可。 代码: #include #include #include #include using namespace std; struct line{ int left,right,n; int mid(){return (left+right)/2;} }a[50010<<2]; unsigned short num[50010]; vo原创 2013-08-27 11:19:43 · 857 阅读 · 0 评论 -
poj3468A Simple Problem with Integers
线段树的应用,注意处理更新的情况,不能单个处理,不然会超时! #include #include #include using namespace std; struct e{ int left,right; long long add; long long sum; }; e tree[400011]; long long a[100001]; long long原创 2013-09-05 21:55:56 · 713 阅读 · 0 评论