
线段树
文章平均质量分 71
Tsaryu
这个作者很懒,什么都没留下…
展开
-
HDU2795 线段树
题目大意: 学校里有个公告栏,公告栏h*w面积,也就是高h,宽w。现在有一些广告需要贴,广告高度都是1,广告尽量往左,往上贴。给你n个广告,问你这个广告在第几层。题目分析: 按照线段树的做法,首先利用h建树,每个结点存储的是该位置和剩余的空间,若左子树的最大值大于他,就查询左子树,否则查询右子树;父结点存储左右子节点的最大剩余值。#include#inclu原创 2016-09-23 22:46:40 · 395 阅读 · 0 评论 -
Just a Hook HDU 1698 线段树区间更新
题目大意: 有一个区间,区间上每个整数点都有个值。现在让你对这些区间进行操作,把从x到y的区间重新赋值为一个数,求赋值过之后的区间总和。题目思路: 一道线段树的题目,题意挺容易理解的,这个题目难度也不很大,一道模板题吧。代码的注释写的比较详细。#include #include #include #include using namespace std;c原创 2016-10-21 16:17:12 · 361 阅读 · 0 评论 -
poj 3468 线段树区间更新 lazy思想
题目大意: 题目挺好理解的,就是给你一串数字,然后会在某一区间上,使区间的所有数字都加上一个数,也就是更新这段区间的数字,最后再进行对某一区间的求值操作。题目分析: 因为这道题目和我之前刚刚做的那道题目很类似,都是区间段更新的题目,但是有所不同的是,那个题目是直接赋值更新,而这个题目是区间进行加和,不是直接赋值,所以就有一点比较麻烦的是,是否需要对单个叶子节点进行更原创 2016-10-22 14:08:34 · 583 阅读 · 0 评论 -
poj 2828 插队买票
题目大意: 现在要买票了,但是有人插队,每个人都有一个自己的属性值,问插队之后他们的属性值的排列顺序。思路:逆序读入,每个结点的值代表还有的空格,一个萝卜一个坑,从后面开始,每个人插队的位置就是他的最终位置。#include#include#include#includeusing namespace std;#define maxn 200005int a[maxn<<2原创 2016-09-27 08:31:48 · 647 阅读 · 0 评论 -
HDU 1698 Just a Hook (线段树区间更新)
In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length. No原创 2017-01-22 22:40:35 · 315 阅读 · 0 评论 -
线段树入门基础(转)
转自:http://blog.youkuaiyun.com/libin56842/article/details/8530197风格:maxn是题目给的最大区间,而节点数要开4倍,确切的说……lson和rson辨别表示结点的左孩子和右孩子。PushUp(int rt)是把当前结点的信息更新到父节点PushDown(int rt)是把当前结点的信息更新给孩子结点。rt表示当前子树的根(r转载 2017-03-03 19:38:08 · 120 阅读 · 0 评论 -
POJ 3468 A Simple Problem with Integers (线段树区间更新经典)
You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for th原创 2017-03-08 11:23:47 · 366 阅读 · 0 评论 -
POJ 2528 (Mayor's posters)(线段树+离散化+lazy思想)
The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council has finally d原创 2017-04-17 23:09:56 · 456 阅读 · 0 评论