![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ACM_线段树&树状数组
文章平均质量分 68
thatTime
这个作者很懒,什么都没留下…
展开
-
线段树 成段更新
关键在于延迟标记hdu 1698给定区间了l, r,将区间内的每一个数都设置为v;// 1698#include const int maxn = 100005;int node[maxn<<2], col[maxn<<2];int t,n, q, ca = 1; int ql, qr, v;void construct(int o, int l, int r){ c原创 2013-11-23 10:47:36 · 791 阅读 · 0 评论 -
hdu 4911
题意:给你n个数, 可以将相邻的两个数交换, 问z原创 2014-08-28 10:47:35 · 734 阅读 · 0 评论 -
hdu 4973
题意:给你n个细胞原创 2014-08-23 16:16:30 · 1142 阅读 · 0 评论 -
hdu 3954
感觉太神了,研究了一天,不过有时候原创 2014-08-04 17:13:57 · 755 阅读 · 0 评论 -
线段树 区间合并
1 poj 3667 题意:支持两种操作 1 如果有连续长度大于D的房间,则输出最左的区间值, 否则输出0;2 将ql, qr区间的房间标记为 未入住思路:节点维护三个域, 该节点的最大房间数,该节点左端点起的最大房间数, 该房间右端点起的最大连续房间数,用线段树进行更新和查询#include #include using namespace s原创 2014-02-17 13:56:33 · 749 阅读 · 0 评论 -
hdu 3397
开一维数组col[]进行延迟标记col[] = -1表示没有要向下传递的操作col[] = 0表示向下传递时将左右区间全部赋值为0col[] = 1表示向下传递时将左右区间全部赋值为1col[] = 2表示向下传递时将左右区间的0变为1, 1变为0 #include #include using namespace std;const int maxn =原创 2014-02-23 13:58:24 · 690 阅读 · 0 评论 -
线段树 单点更新
HDU 2795题意:要求所贴广告在广告牌的最上面 最左边, 求每张广告对应的所在行数#include #include using namespace std;int node[(200000<<2) + 10];int h, w, n, x;void construct(int o, int l, int r){ node[o] = w; if(l != r)原创 2013-11-10 01:21:40 · 699 阅读 · 0 评论 -
线段树 单点更新
hdu 1394题意:给出一个0到n-1的排列, 求题目所给的所有形式的最小逆序数1 暴力#include #include using namespace std;int a[5010], n;int main(){ while(scanf("%d", &n) == 1) { int ans1, ans = 0; for(int i=1; i原创 2013-11-10 01:17:30 · 917 阅读 · 0 评论 -
uva11992
第一次做uva上的题目, 感觉题目的综合性还是蛮好的, 以后应该多做做uva上的题目,要考虑的东西挺多的快速矩阵变换, 支持3个操作1 将所给区间内的每个数加上v;2 将所给区间内的每个数更新为v;3 求所给区间的和, 最小值, 最大值需要两个延迟标记 addv[o], setv[o]#include #include using namespace st原创 2013-11-23 10:56:13 · 941 阅读 · 0 评论 -
hdu 4819
二维线段树, 单点更新 + 区间查询(cu)原创 2014-11-16 15:31:32 · 739 阅读 · 0 评论