![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
线段树
文章平均质量分 79
ElephantFlySong
这个作者很懒,什么都没留下…
展开
-
HDU2795
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2795信息最多200000条,所以高度也不会超过200000,以高度为下标建立线段树(1 到 n ),初始值全都是w,保留最大值,每次取最大值,取完之后直接在query里面减去wi的长度,并更新。#include #include #define lson l, m, x<<1#defin原创 2017-04-10 16:26:17 · 312 阅读 · 0 评论 -
HDU1698
题目链接:区间替换,区间求和,模板题。#includeusing namespace std;typedef long long ll;ll sum[200020];ll delta[200020];ll cnt[200020];int d, ql, qr;ll tmp;void PushUp(int x){ sum[x] = sum[x<<1] + sum原创 2016-08-19 23:09:00 · 337 阅读 · 0 评论 -
POJ2528
题目链接:http://poj.org/problem?id=2528区间增减模板题,不论是update还是query中都要进行下放标记。#include #include #define lson l, m, x<<1#define rson m+1, r, x<<1|1using namespace std;typedef long long type;const in原创 2017-04-11 20:28:52 · 250 阅读 · 0 评论 -
POJ3667
题目链接:http://poj.org/problem?id=3667题意:1 a:询问是不是有连续长度为a的空房间,有的话住进最左边2 a b:将[a,a+b-1]的房间清空思路:记录区间中最长的空房间#include#include#define min(a,b) (a)<(b)?(a):(b)using namespace std;const int INF原创 2016-08-18 15:40:49 · 363 阅读 · 0 评论 -
HDU1542
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1542矩形面积并对于浮点数的离散化,真心看不懂啊……#include #include #include #include using namespace std;#define lson l , m , rt << 1#define rson m + 1 , r , rt <原创 2017-04-16 15:39:35 · 294 阅读 · 0 评论