线段树
凌晨四点的洛杉矶fly
这个作者很懒,什么都没留下…
展开
-
POJ 2828 线段树 插队排列顺序
题目: 火车站有n个人排队,他们是按顺序到达的,但是他们乱插队。每个人有两个值pos[i]和val[i]。比如现在第5个人来了,他的pos[5]值为3,那么他就会插队到当前第3个人位置的后面(第0个人是售票窗口)。依次给出所有人的pos和val值,要你最终按所有人的位置顺序输出val值。 #include<cstdio>#include<cstring>#i...原创 2018-11-12 21:50:54 · 191 阅读 · 0 评论 -
二维rmq(线段树)
Paul draw a big m*n matrix A last month, whose entries Ai,j are all integer numbers ( 1 <= i <= m, 1 <= j <= n ). Now he selects some sub-matrices, hoping to find the maximum number. Then ...原创 2019-02-16 20:07:03 · 147 阅读 · 0 评论 -
线段树HDU 5493
题意转:1:题意:给你n个人的身高和他前面或者后面身高大于他的人的个数,求一个字典序最小的满足此条件的序列,如果不存在输出“impossible”。分析:我们从字典序最小入手,如果一个位置可以放多个数,那么肯定放最小的,所以我们从小到大处理,并且小的数不影响大的数的放置,因为第一个值是比当前人身高大的人的个数。那么我们考虑当前数(保证处理的数是未处理集合中最小的那个),可以存放的...原创 2019-01-15 21:45:23 · 148 阅读 · 0 评论 -
hdu4614(线段树+二分)
Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flowers, she will try to put them in the vases, one flower in one vase....原创 2019-01-19 16:21:21 · 170 阅读 · 1 评论 -
hdu3397(线段树多种操作)
lxhgww got a sequence contains n characters which are all '0's or '1's. We have five operations here: Change operations: 0 a b change all characters into '0's in [a , b] 1 a b change all charac...原创 2019-01-23 19:58:30 · 114 阅读 · 0 评论 -
求矩形面积且矩形是镂空的
详细讲解<span style="font-size:18px;">#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int MAXN=55555;#define lson i*2,l,m#define rson i*2+1,...原创 2018-11-17 20:03:57 · 173 阅读 · 0 评论 -
线段树(扫描线)扫描线求矩形外边界周长
详细讲解#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int MAXN=22222;#define lson i*2,l,m#define rson i*2+1,m+1,rint cnt[MAXN*4],suf[MAXN*4],pr...原创 2018-11-17 20:02:41 · 138 阅读 · 0 评论 -
线段树(扫面线)
详细讲解:扫描线详细讲解扫描线模板:#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int MAXN=2222;#define lson i*2,l,m#define rson i*2+1,m+1,r#define root 1,1...原创 2018-11-16 11:32:34 · 83 阅读 · 0 评论 -
线段树染色问题(区间一共有多少种不同颜色)poj2777
描述选择问题解决和程序设计作为选修课程,您需要解决各种问题。在这里,我们遇到了一个新问题。 有一个很长的板长L厘米,L是正整数,所以我们可以将板均分为L段,从左到右标记为1,2,...... L,每个为1厘米长。现在我们必须为电路板上色 - 只有一种颜色的一个部分。我们可以在电路板上执行以下两项操作:1。“CAB C”将电路板从A段染色到B段,颜色为C. 2.“PA B”输出A段和...原创 2018-11-16 10:06:51 · 781 阅读 · 0 评论 -
hdu2795 线段树应用:找到线段树中>=给定值的第一个元素位置 并 更新该点)
问题描述在大学的入口处,有一个巨大的矩形广告牌,大小为h * w(h是它的高度,w是它的宽度)。董事会是发布所有可能公告的地方:最近的节目比赛,餐厅菜单的变化以及其他重要信息。9月1日,广告牌是空的。一个接一个,公告开始被放在广告牌上。每个公告都是单位高度的纸条。更具体地,第i个通告是大小为1 * wi的矩形。当有人在广告牌上发布新的公告时,她总是会选择公告的最高位置。在所有可能的最...原创 2018-11-12 20:53:48 · 227 阅读 · 0 评论 -
线段树:HDU 1698:区间set,区间查询
就是ba区间的每一个值都变成某个数。//POJ 3468 区间add,区间查询#include<cstdio>#include<cstring>#include<algorithm>using namespace std; //每当有add加到i节点上,不会去更新i节点的sum.//也就是说如果要查询区间[1,n]的sum值,既要考虑sum...原创 2018-11-13 21:23:51 · 127 阅读 · 0 评论 -
线段树:区间add,区间查询
//POJ 3468 区间add,区间查询#include<cstdio>#include<cstring>#include<algorithm>using namespace std; //每当有add加到i节点上,直接更新i节点的sum.//也就是说如果要查询区间[1,n]的sum值,直接sum[1]即可,不用再去考虑1的addv[1]值....原创 2018-11-13 20:29:51 · 101 阅读 · 0 评论 -
线段树单点替换区间最值 及思想
线段树详细讲解:https://www.cnblogs.com/TheRoadToTheGold/p/6254255.html上面的博客讲解的线段树(包括区间修改)非常好,模板写的也很好。<span style="font-size:18px;">//HDU1754#include<cstdio>#include<cstring>#includ...原创 2018-11-11 18:42:24 · 187 阅读 · 0 评论 -
poj3277(扫面线)
Farmer John has taken his cows on a trip to the city! As the sun sets, the cows gaze at the city horizon and observe the beautiful silhouettes formed by the rectangular buildings.The entire horizon ...原创 2019-06-07 21:19:27 · 184 阅读 · 0 评论