![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构--线段树
pxlsdz
冲就完了!
展开
-
HDU6609 Find the answer 权值线段树+思维
OJ题号HDU6609 Find the answer简单题意给n个数,前i−1个至少要把几个变成0才能使前i项的和<=m。正解思路思路来自:https://blog.csdn.net/Ratina/article/details/97798320对于每一个a[i],前缀和sum[i],当sum[i]≤m,则ans[i]=0; 当sum[i]...原创 2019-09-25 22:20:53 · 246 阅读 · 0 评论 -
HDU 6606 Distribution of books (DP+线段树)
Distribution of books Time Limit: 8000/8000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1404Accepted Submission(s): 547 Problem Description...原创 2019-10-16 00:12:19 · 309 阅读 · 0 评论 -
HDU6602 Longest Subarray(思维+线段树区间修改维护最值)
Longest Subarray Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 2206Accepted Submission(s): 790 Problem Description ...原创 2019-10-15 20:05:28 · 245 阅读 · 0 评论 -
HDU6592 - Beauty Of Unimodal Sequence(贪心,线段树+LIS+单峰)
Beauty Of Unimodal SequenceTime Limit: 8000/4000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 734Accepted Submission(s): 262Problem DescriptionYou a...原创 2019-10-15 09:59:56 · 323 阅读 · 0 评论 -
牛客练习赛53
题号 标题 已通过代码 题解 讨论 通过率 我的状态 A 超越学姐爱字符串 点击查看 进入题解 进入讨论 798/1844 通过 B 美味果冻 点击查看 进入题解 进入讨论 245/1119 未通过 C 富豪凯匹配串 点击查看 进入题解 进入讨论 ...原创 2019-10-13 23:24:52 · 340 阅读 · 0 评论 -
51nod 1391 01串(思维+前缀和或者线段树)
给定一个01串S,求出它的一个尽可能长的子串S[i..j],满足存在一个位置i<=x <j, S[i..x]中0比1多,而S[x + 1..j]中1比0多。求满足条件的最长子串长度。收起输入一行包含一个只由0和1构成的字符串S。 S的长度不超过1000000。输出一行包含一个整数,表示满足要求的最长子串的长度。输入样例10输出样例0...原创 2019-04-30 20:36:26 · 342 阅读 · 0 评论 -
2019中山大学程序设计竞赛 K. Party(吉司机线段树)
PartyTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 235Accepted Submission(s): 87Problem Descriptionnperson have just entered a c...原创 2019-04-23 09:27:28 · 446 阅读 · 0 评论 -
POJ 3667 Hotel(线段树:区间覆盖+维护最大连续子区间长度)
Hotel Time Limit:3000MS Memory Limit:65536K Total Submissions:21673 Accepted:9442 Description The cows are journeying north to Thunder Bay in Cana...原创 2019-04-06 13:58:28 · 294 阅读 · 0 评论 -
UVA 1400 "Ray, Pass methe dishes!"(线段树,区间合并)
UVA 1400 - "Ray, Pass me the dishes!"题意:给出一个长度为n的整数序列D,你的任务是对m各询问做出回答。对于询问(a,b),需要找到两个下标x和y,使得a<=x<=y<=b,并且Dx+Dx+1+...+Dy尽量大。如果有多组满足条件的x和y,x应该尽量小。如果还有多解,y应该尽量小。分析:本题详解...原创 2019-04-05 21:44:48 · 160 阅读 · 0 评论 -
线段树/树状数组复习
比赛地址:https://cn.vjudge.net/contest/283393#rank水题和模板题就不贴了。1.HDU 6315 Naive Operations 【线段树+思维】 这题依旧没做出来,这题的思维难想,首先需要想到线段树要维护三个值,数组a的最大值maxa,数组b的最小值minb,答案sum,当minb<=maxa&&更新到点的时候...原创 2019-04-05 16:12:38 · 147 阅读 · 0 评论 -
HDU 6315 Naive Operations【线段树+思维】
传送门题面:Naive OperationsTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 502768/502768 K (Java/Others)Total Submission(s): 650 Accepted Submission(s): 239Problem DescriptionIn a galaxy...原创 2019-02-14 13:12:45 · 207 阅读 · 0 评论 -
hdu3486 Interviewe (枚举(二分错误)+线段树求区间最值)
IntervieweTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8797 Accepted Submission(s): 2077 Problem DescriptionYaoYao has a company a...原创 2019-02-17 01:17:27 · 296 阅读 · 0 评论 -
HDU - 3397 Sequence operation (线段树,区间修改,亦或,查询,以及最长连续的1)
Sequence operationTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9078 Accepted Submission(s): 2765 Problem Descriptionlxhgww got a ...原创 2019-01-30 23:43:22 · 242 阅读 · 0 评论 -
Codeforces217E Alien DNA 树状数组+逆向思考
CodeForces - 217EProfessor Bajtocy is conducting experiments on alien DNA. He has discovered that it is subject to repetitive mutations — each mutation happens in the same way: some continuous subs...原创 2019-07-29 17:55:16 · 442 阅读 · 0 评论 -
ACM-ICPC 2018 徐州赛区网络预赛 - G Trace - 思维
There's a beach in the first quadrant. And from time to time, there are sea waves. A wave (xx,yy) means the wave is a rectangle whose vertexes are (00,00), (xx,00), (00,yy), (xx,yy)...原创 2019-08-02 18:11:12 · 138 阅读 · 0 评论 -
[计蒜之道2019 复赛 A]外教 Michale 变身大熊猫 (线段树求LIS+思维)
外教变身萌翻小学员,VIPKID “AR 变脸” 打造趣味互动课堂,这是在线少儿英语品牌 VIPKID 全新推出的辅助教学功能——AR 变脸,外教在上课过程中可以随意选取合适的表情贴纸。人脸识别和表情识别等技术的应用帮助“AR 变脸”这一教辅功能更好地服务外教,更好地激励学生积极地参与课堂内容,提升在线课堂的趣味性。现在,外教 Michale 就变身了一只萌萌的大熊猫,给你出来了一道关于数列的...原创 2019-08-30 17:28:00 · 263 阅读 · 0 评论 -
HDU 6703 array 2019CCPC网络选拔赛 1002 (线段树/权值线段树/主席树+set)
arrayTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1356Accepted Submission(s): 522Problem DescriptionYou are given an arraya1,...原创 2019-08-26 17:48:22 · 296 阅读 · 0 评论 -
51nod 1672 区间交 线段树+贪心或优先队列+贪心
1672 区间交1.0 秒 131,072.0 KB 40 分 4级题小A有一个含有n个非负整数的数列与m个区间,每个区间可以表示为li,ri。它想选择其中k个区间, 使得这些区间的交的那些位置所对应的数的和最大。(是指k个区间共同的交,即每个区间都包含这一段,具体可以参照样例)在样例中,5个位置对应的值分别为1,2,3,4,6,那么选择[2,5]与[4,5]...原创 2019-08-07 17:40:19 · 150 阅读 · 0 评论 -
HDU 4578 Transformation(线段树+区间乘法+多重懒惰标记)
TransformationTime Limit: 15000/8000 MS (Java/Others)Memory Limit: 65535/65536 K (Java/Others)Total Submission(s): 10723Accepted Submission(s): 2817Problem DescriptionYuanfang is puzz...原创 2019-08-13 14:57:09 · 191 阅读 · 0 评论 -
线段树/树状数组复习总结 (未完待续)
线段树的遇到的题型主要分为两种:思维+线段树/树状数组、线段树的修改结构、扫描线。第一种:思维+线段树,线段树不是难点,关键如何应用线段树或者该运用线段树的解决什么问题。例题:4302 Interval GCD 线段树 +树状数组 线段树维护数组区间GCD 数学知识点:gcd ( x,y,z )= gcd( x,y-x,z-y );可继续扩展到n元HDU ...原创 2019-08-05 21:41:50 · 156 阅读 · 0 评论 -
Codeforces 240 F. TorCoder 线段树
A boy named Leo doesn't miss a single TorCoder contest round. On the last TorCoder round number 100666 Leo stumbled over the following problem. He was given a strings, consisting ofnlowercase Engli...原创 2019-08-01 17:03:53 · 197 阅读 · 0 评论 -
51NOD 1287 加农炮 线段树修改查询函数
1287 加农炮1.0 秒 131,072.0 KB 20 分 3级题一个长度为M的正整数数组A,表示从左向右的地形高度。测试一种加农炮,炮弹平行于地面从左向右飞行,高度为H,如果某处地形的高度大于等于炮弹飞行的高度H(A[i] >= H),炮弹会被挡住并落在i - 1处,则A[i - 1] + 1。如果H <= A[0],则这个炮弹无效,如果H >...原创 2019-08-04 15:40:20 · 161 阅读 · 0 评论 -
Codeforces 242 E XOR on Segment 异或线段树
You've got an arraya, consisting ofnintegersa1, a2, ..., an. You are allowed to perform two operations on this array:Calculate the sum of current array elements on the segment[l, r], that is, c...原创 2019-08-03 12:55:54 · 185 阅读 · 0 评论 -
HDU - 3003 - Pupu (快速幂取模!)
PupuTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1133 Accepted Submission(s): 445Problem DescriptionThere is an island called PiLiPa...原创 2019-02-15 16:16:24 · 252 阅读 · 0 评论 -
HDU_3183_A Magic Lamp(贪心/线段树)
A Magic LampTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2274 Accepted Submission(s): 902Problem DescriptionKiki likes traveling. On...原创 2019-02-16 01:25:57 · 197 阅读 · 0 评论 -
HDU2888 Check Corners(二维线段树)
Check CornersTime Limit: 2000/10000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3599Accepted Submission(s): 1290Problem DescriptionPaul draw a big m*...原创 2019-02-15 18:57:31 · 225 阅读 · 0 评论 -
HDU 2795 Billboard (线段树单点更新)
BillboardTime Limit: 20000/8000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 29637 Accepted Submission(s): 11993 Problem DescriptionAt the entrance to t...原创 2019-01-12 19:22:30 · 337 阅读 · 0 评论 -
HDU 1394 Minimum Inversion Number(线段树:单点更新,区间求和或树状数组:求逆序对)
The 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, ..., an, if w...原创 2019-01-12 16:10:24 · 226 阅读 · 3 评论 -
HDU - 1754 B - I Hate It 线段树模板
I Hate It Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 107455 Accepted Submission(s): 40327 Problem Description 很多学...原创 2019-01-12 11:01:49 · 167 阅读 · 0 评论 -
线段树应用:扫描线
扫描线暴力解决的话时间和空间复杂度往往是不够的。所以,扫描线也就成了线段树很大的应用。具体原理解释(写得很好):https://blog.csdn.net/u013480600/article/details/22548393https://blog.csdn.net/zearot/article/details/48299459#t19https://www.cnblogs....原创 2018-11-18 00:05:05 · 290 阅读 · 0 评论 -
HDU 1542 Atlantis(线段树:扫描线)
Atlantis Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 19655 Accepted Submission(s): 7893 Problem Description There ...原创 2018-11-18 00:01:02 · 203 阅读 · 0 评论 -
POJ3368_Frequent values_
Frequent values Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 22993 Accepted: 8051 De...原创 2018-11-14 23:01:00 · 150 阅读 · 0 评论 -
4302 Interval GCD 线段树 +树状数组
题目地址:http://contest-hunter.org:83/contest/0x40%E3%80%8C%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E8%BF%9B%E9%98%B6%E3%80%8D%E4%BE%8B%E9%A2%98/4302%20Interval%20GCD描述给定一个长度为N的数列A,以及M条指令 (N≤5*10^5, M<...原创 2018-11-11 20:41:59 · 325 阅读 · 0 评论 -
线段树
前言具体了解原理:《算法竞赛进阶指南》讲得贼好,但缺了一个区间修改(整段区间赋值),可以看看《算法入门经典指南》刘汝佳,写得也挺好。这篇线段树知识点博客:https://blog.csdn.net/zearot/article/details/48299459线段树题目博客:https://blog.csdn.net/weizhuwyzc000/article/details/...原创 2018-11-11 20:31:41 · 360 阅读 · 0 评论 -
HDU 1166 敌兵布阵(线段树:单点更新+区间求和) 两种模板
敌兵布阵 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 127746 Accepted Submission(s): 53528 Problem Description C国的死对头A国...原创 2018-11-11 19:22:09 · 209 阅读 · 0 评论 -
SP1716 GSS3 - Can you answer these queries III 线段树(结构体模板)
题意翻译nn个数,qq次操作操作0 x y把A_xAx修改为yy操作1 l r询问区间[l, r][l,r]的最大子段和感谢 @Edgration 提供的翻译题目描述You are given a sequence A of N (N <= 50000) integers between -10000 and 10000. On this sequence ...原创 2018-11-08 23:02:23 · 296 阅读 · 0 评论 -
POJ 2828 Buy Tickets(线段树:查找并更新从左到右第i个1或树状数组:统计1的个数)
Buy TicketsTime Limit: 4000MS Memory Limit: 65536K Total Submissions: 25204 Accepted: 12130 DescriptionRailway tickets were difficult to buy around the Lunar New Year in China,...原创 2019-01-13 01:08:31 · 179 阅读 · 0 评论 -
UVA 11992 Fast MatrixOperations(线段树:区间查询+区间赋值+区间增值)
题目描述PDF输入输出格式输入格式: 输出格式: 输入输出样例输入样例#1: 复制4 4 81 1 2 4 4 53 2 1 4 41 1 1 3 4 23 1 2 4 43 1 1 3 42 2 1 4 4 23 1 2 4 41 1 1 4 3 3输出样例#1: 复制45 0 578 5 769 ...原创 2019-01-13 14:37:23 · 376 阅读 · 0 评论 -
POJ 2528 Mayor's posters(线段树+离散化)
Mayor's postersTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 32200 Accepted: 9347 DescriptionThe citizens of Bytetown, AB, could not stand that the candidates in t...原创 2019-02-15 02:40:20 · 126 阅读 · 0 评论 -
HDU 3974 Assign the task(dfs序+线段树)
Assign the taskTime Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4809 Accepted Submission(s): 1909Problem DescriptionThere is a company ...原创 2019-02-15 01:26:00 · 238 阅读 · 0 评论