线段树
Error Man
我是菜逼
展开
-
Gym 101889F. Fundraising(线段树 + dp)
题意: n 个人,每一个人都 x , y , v 三个属性. 现在要选取若干个人形成一个集合,这个集合需要满足的条件是,集合内的任意两个人A,B都符合 (A.x == B.x && A.y == B.y) || (A.x < B.x && A.y < B.y) || (A.x > B.x && A.y > B.y),最大化集...原创 2019-10-23 15:40:30 · 205 阅读 · 0 评论 -
POJ - 3225 Help with Intervals (区间置0/1与区间异或混合操作)
Help with IntervalsLogLoader, Inc. is a company specialized in providing products for analyzing logs. While Ikki is working on graduation design, he is also engaged in an internship at LogLoader. Am...原创 2019-07-15 11:28:38 · 257 阅读 · 0 评论 -
poj 2481 Cows (n 个区间,每个区间被其他多少个区间完全覆盖)
CowsFarmer John's cows have discovered that the clover growing along the ridge of the hill (which we can think of as a one-dimensional number line) in his field is particularly good.Farmer John...原创 2019-07-10 23:25:10 · 249 阅读 · 0 评论 -
poj 2828 Buy Tickets(插队问题,线段树)
uy TicketsTime Limit:4000MS Memory Limit:65536K Total Submissions:15869 Accepted:7905 DescriptionRailway tickets were difficult to buy around the Lunar New Year in China...原创 2019-07-11 15:27:30 · 232 阅读 · 0 评论 -
HDU - 4288 Coder(5棵 线段树)
Coder In mathematics and computer science, an algorithm describes a set of procedures or instructions that define a procedure. The term has become increasing popular since the advent of cheap and re...原创 2019-07-15 21:53:07 · 199 阅读 · 0 评论 -
HDU 4614 Vases and Flowers(线段树update剪枝,从左至右非连续填充1)
Vases and Flowers 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 fl...原创 2019-07-11 16:43:29 · 108 阅读 · 0 评论 -
FZU 1608 Huge Mission(线段树,update剪枝)
Huge MissionOaiei is busy working with his graduation design recently. If he can not complete it before the end of the month, and he can not graduate! He will be very sad with that, and he needs you...原创 2019-07-11 17:15:26 · 136 阅读 · 0 评论 -
HDU - 3564 Another LIS(线段树(最值) + 线段树解决插队问题)
做这个题之前,建议先做 POJ 2828. 附题解POJ 2828题解Another LISThere is a sequence firstly empty. We begin to add number from 1 to N to the sequence, and every time we just add a single number to the sequ...原创 2019-07-16 11:18:09 · 213 阅读 · 1 评论 -
HDU - 3071 Gcd & Lcm game (线段树 + 素数拆分 + 状压)
Gcd & Lcm gameTired of playing too much computer games, alpc23 is planning to play a game on numbers. Because plus and subtraction is too easy for this gay, he wants to do some gcd and lcm oper...原创 2019-07-12 01:04:16 · 210 阅读 · 1 评论 -
HDU 6609 (2019杭电多校三 1007)Find the answer (权值线段树 + 二分 查询前 k 大的和)
Find the answerTime Limit: 4000/4000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 470Accepted Submission(s): 149Problem DescriptionGiven a sequence of n...原创 2019-07-29 20:46:49 · 447 阅读 · 0 评论 -
洛谷 4513(带修的查询区间最大子段和,线段树区间合并)
题目背景小新经常陪小白去公园玩,也就是所谓的遛狗啦…题目描述在小新家附近有一条“公园路”,路的一边从南到北依次排着nn个公园,小白早就看花了眼,自己也不清楚该去哪些公园玩了。一开始,小白就根据公园的风景给每个公园打了分-.-。小新为了省事,每次遛狗的时候都会事先规定一个范围,小白只可以选择第aa个和第bb个公园之间(包括aa、bb两个公园)选择连续的一些公园玩。小白当然希望选出的公...原创 2019-08-08 00:14:02 · 588 阅读 · 0 评论 -
HDU 6638(稀疏矩阵的最大子矩阵和)
Snowy SmileTime Limit: 4000/4000 MS (Java/Others)Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1094Accepted Submission(s): 361Problem DescriptionThere arenpirate c...原创 2019-08-08 10:53:53 · 540 阅读 · 0 评论 -
2019 牛客多校 第七场 E.Find the Median (线段树,(叶子) 点代区间)
戳我看题题意:有 n 次操作,每一次操作都向集合中插入 [L,R] 之间的所有数。询问每次操作之后的中位数思路:第一次写叶子节点代替一个区间这样的题。首先肯定是对所有端点离散化,但是离散化的时候需要将右端点 + 1(这样就表示一个左闭右开的区间)。例:L = [2, 4]R = [7, 8](右端点 + 1)离散化后有:数组 Ls: 2 5 7 9...原创 2019-08-09 15:46:39 · 133 阅读 · 0 评论 -
HDU 5592 ZYB's Premutation (线段树,构造序列满足前缀逆序对数目)
ZYB’s PremutationZYB has a premutation P,but he only remeber the reverse log of each prefix of the premutation,now he ask you torestore the premutation.Pair (i,j)(i<j) is considered as a reverse...原创 2019-09-05 12:38:27 · 186 阅读 · 0 评论 -
Codeforces 1208D.Restore Permutation (构造数组[每个数属于1~n],满足 i 位置前缀小于 B[i] 的数的和 == A[i])
Restore Permutation题目连接题意: 有一个数组未知数组 B,给一个数组AAA,A[i]A[i]A[i] 表示 iii 的前缀比 B[i]B[i]B[i] 小的数的和。还原数组 B, 满足数组 A 这个条件。思路: 和 HDU 5592 区别不大。从后往前还原,假设现在还原的是最后一个数 x ,那么二分枚举这个数 x ,满足条件 A[n]A[n]A[n] 即可,然后删掉 x,...原创 2019-09-05 19:14:15 · 316 阅读 · 0 评论 -
ZOJ 2859 Matrix Searching(二维线段树,树套树)
Matrix SearchingGiven an n*n matrix A, whose entries Ai,j are integer numbers ( 1 <= i <= n, 1 <= j <= n ). An operation FIND the minimun number in a given ssub-matrix.InputThe first...原创 2019-07-14 10:21:50 · 184 阅读 · 0 评论 -
HDU - 1823 Luck and Love(二维线段树查询矩阵最值,树套树与四叉树 + 单点修改,区间查询)
Luck and Love世界上上最远的距离不是相隔天涯海角而是我在你面前可你却不知道我爱你―― 张小娴前段日子,枫冰叶子给Wiskey做了个征婚启事,聘礼达到500万哦,天哪,可是天文数字了啊,不知多少MM蜂拥而至,顿时万人空巷,连扫地的大妈都来凑热闹来了。―_―|||由于人数太多,Wiskey实在忙不过来,就把统计的事情全交给了枫冰叶子,...原创 2019-07-14 10:14:11 · 336 阅读 · 0 评论 -
Codeforces 1185 C2. Exam in BerSU (hard version)(权值线段树 + 二分 查询前 K 大的和)
题目:题目链接题意:给定一个长度为 n 的数组 a 和 一个数 M,问对于每一个 i ,在区间 [1,i - 1] 删除最少的数,使得[1,i - 1]中剩下的数的和 + a[i] <= M,问最少删除多少个数。思路:显然要删除最少个数,肯定是从大到小进行删除,关键就是怎么确定从大到小的数的和,这就是需要解决的问题。那么我是用权值线段树来进行维护的如整个区间第 k 大一样,然后查询的...原创 2019-07-09 22:40:57 · 453 阅读 · 0 评论 -
codeforces 580E (线段树 + 字符串哈希)
======>蒟蒻的博客,写错的地方,请见谅。题目:传送门题意:给你三个整数n,m,k, n 代表一个字符串的长度为n。紧接着有 m + k 个操作。将 l 到 r 的字符全部更换为字符 c ,或查询从 l 到 r,该子段字符串循环节是否为 c.思路:由于该蒟蒻很少写哈希,而且又很菜,花了挺长时间写这个题目的,也算是有挺大的收获,对多项式哈希理解很多。多项式哈希,即:...原创 2019-03-26 16:16:43 · 447 阅读 · 0 评论 -
CodeForces - 768B Code For 1 (线段树思想 二分)
Code For 1Jon fought bravely to rescue the wildlings who were attacked by the white-walkers at Hardhome. On his arrival, Sam tells him that he wants to go to Oldtown to train at the Citadel to becom...原创 2018-08-28 15:06:14 · 176 阅读 · 0 评论 -
气温预测(线段树)
气温预测 Time Limit 1500MS Memory Limit 256MB 看样例 Hint, 很容易明白题意。 太难了,看标程 才明白。 QAQ思路:线段树,以值 a[i] 作为区间, 维护 大于值a[i] 的最大下标AC代码:#include<bits/stdc++.h>using namespace std;c...原创 2018-08-08 21:05:03 · 634 阅读 · 0 评论 -
HDU 1255(线段树 + 离散化 + 扫描线)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1255思路: 与扫描线求面积并类似。在面积并的基础上 多增加一个 sum2[] 数组,存放覆盖两次及以上的投影。具体看代码AC代码:#include<cstdio>#include<algorithm>#include<cstring>using ...原创 2018-07-26 22:33:49 · 223 阅读 · 0 评论 -
HDU 1542(线段树 + 离散化 + 扫描线)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1542题意: 给你n个矩形的左上角顶点与右下角顶点, 求 n个矩形的面积和(可能重叠,重叠的部分只算一次)。思路: 扫描线模版题。关于扫描线建议看这个博客:http://www.cnblogs.com/scau20110726/archive/2013/04/12/3016765.html...原创 2018-07-26 20:08:50 · 266 阅读 · 0 评论 -
HDU 1540(线段树 区间合并)
Tunnel Warfare Time Limit: 4000/2000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 12163Accepted Submission(s): 4765 Problem Description ...原创 2018-07-25 22:48:50 · 179 阅读 · 0 评论 -
线段树区间合并....模版
https://blog.csdn.net/Diogenes_/article/details/80471916转载 2018-07-25 22:40:51 · 302 阅读 · 0 评论 -
POJ 2528 (线段树 + 离散化)
Mayor's postersDescriptionThe 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. ...原创 2018-07-25 16:11:11 · 330 阅读 · 0 评论 -
HDU 4027 (线段树, 区间和(对区间内的每一个数操作不同),单点更新)
Can you answer these queries? Time Limit: 4000/2000 MS (Java/Others)Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 22963Accepted Submission(s): 5451 Problem D...原创 2018-07-24 20:46:47 · 497 阅读 · 0 评论 -
线段树模版(区间延迟更新)
///区间求和const int maxn=100000;int N,Q; // N为区间右端点(即数的个数),Q为查询次数long long m;struct xx{ long long sum,inf; //inf,延迟更新,当需要更新时才更新,否则存放入 inf}tree[4*maxn+10]; /...原创 2018-07-24 11:59:08 · 241 阅读 · 0 评论 -
HDU 1394 (每次将序列第一个数放到最后形成一个新序列,求这些序列的逆序对的最小值)
Minimum Inversion NumberThe inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i < j and ai > aj.For a given sequence of numbers a1, a2,...原创 2019-05-14 16:58:15 · 473 阅读 · 0 评论 -
Gym - 101350F Monkeying Around( 线段树区间染色 + 差分)
Monkeying AroundWhen the monkey professor leaves his class for a short time, all the monkeys go bananas.Nmonkeys are lined up sitting side by side on their chairs. They each have the same joke boo...原创 2019-05-21 19:39:42 · 236 阅读 · 0 评论 -
南昌网络赛 I 题,max answer(单调栈 + 线段树)
max answerAlice has a magic array. She suggests that the value of a interval is equal to the sum of the values in the interval, multiplied by the smallest value in the interval.Now she is planning...原创 2019-04-24 21:28:03 · 352 阅读 · 0 评论 -
POJ - 2777 Count Color (线段树区间染色 ,统计颜色 + 或运算妙用)
POJ - 2777Chosen Problem Solving and Program design as an optional course, you are required to solve all kinds of problems. Here, we get a new problem.There is a very long board with length L cen...原创 2019-05-22 14:42:40 · 316 阅读 · 0 评论 -
bzoj 1503 (权值线段树)
由于蒟蒻实在是ttttttai 菜了,于是开始了学习主席树,权值线段树作为主席树的前置知识,于是蒟蒻各种百度百度,谷歌谷歌,抄网上的代码,然后终于A了这个题目。也还算是有一点收获。题目:芝麻开门题意:中文题,不解释。思路:首先 升工资和降工资 可以用一个偏移量 tmp 来表示,但会有一个问题,因为可以在升工资和降工资之前新增成员,假设一开始就是满员工,那么升工资 tmp 直接 += ,...原创 2019-04-19 11:39:03 · 259 阅读 · 0 评论