
线段树_树状数组
文章平均质量分 73
斩-AC
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
HDU_1166_线段树
题意:给你一个数列,让你维护一个区间询问和区间查询,线段树或者树状数组: 1.线段树代码: #include #include #include #include using namespace std; const int N =50000 + 100; int sum[N<<2]; void bulid(int l, int r, int rt) { if(l ==原创 2015-03-31 16:46:25 · 382 阅读 · 0 评论 -
HDU_1754_线段树
题意:区间最值问题,线段树模板水题: #include #include using namespace std; const int N = 200000 + 10; int maxnumb[N<<2]; int MAX(int a, int b) { return a<b ? b : a; } void build(int l, int r, int rt) { if原创 2015-03-31 16:49:38 · 388 阅读 · 0 评论 -
HDU_2795_线段树
题意:h*w的广告牌,每次放一个1*a的广告,且最先放到最上边。线段树的简单题区间查找最大值的位置然后放进去,更新放进后的信息: #include #include using namespace std; const int N = 200000 << 2; int n, h, w; int Max[N]; int MAX(int a, int b) { return a>原创 2015-04-02 15:05:12 · 384 阅读 · 0 评论 -
HDU_1698_区间更新
题意:区间更新,给你一个区间a,b更新为c值,询问总区间的值和: #include #include #include using namespace std; const int N = 100000 + 10; int cal[N<<2], sum[N<<2]; void updown(int rt, int c) { if(cal[rt]) {原创 2015-04-02 17:09:16 · 343 阅读 · 0 评论 -
HDU_1394_线段树_树状数组
题意:求逆序数,给你n个数,符合ai>aj i 1.暴力解法,记录初始序列的逆序数的总个数,每将第一个数放在最后的时候总的数目将增加n-1-a[i]个,将减少a[i]个,所以对于每个数sum += n-1-a[i]-a[i],记录最小的sum,暴力代码: #include #include using namespace std; const int N = 5000 + 5原创 2015-03-31 16:39:49 · 400 阅读 · 0 评论 -
HDU4267
题意:第一行一个n,表示数的个数,下面一行n个数是初始数值,然后一行一个数m代表m个询问数,1 a b k c代表a到b区间内每隔k个数加c;2 a代表询问a出的值。树状数组可解,如果是对a到b区间内的所有数加c用树状数组很好解决,对于此题,由于是a、b间每隔k个数才进行更新,k的值在10之内,取余数也比较少可以对对应每个k建一棵树,对应的每个余数进行更新,数组定义就变成了C[N][11][11]原创 2015-05-22 22:24:00 · 631 阅读 · 0 评论