![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
线段树
文章平均质量分 84
键盘上的舞者
这个作者很懒,什么都没留下…
展开
-
BAPC2014 E&&HUNNU11585:Excellent Engineers(线段树)
题意:有n个程序员,每个程序员有三个能力值,当一个程序员三个能力值都小于另外一个程序员的时候,那么就可以淘汰那个程序员,问经过淘汰之后,还剩下几个程序员。思路:我们首先按照x排序,那么我们就只需要考虑y,z的情况了,这个时候可以用线段树,我们以y作为区间,以z作为值,每次查询只需要看1~y-1区间内是否已经存在小于z的值,如果存在,那么这个人就要淘汰#include原创 2015-08-12 23:37:21 · 1676 阅读 · 0 评论 -
FZU2171:防守阵地 II(线段树)
Problem Description部队中总共有N个士兵,每个士兵有各自的能力指数Xi,在一次演练中,指挥部确定了M个需要防守的地点,指挥部将选择M个士兵依次进入指定地点进行防守任务,获得的参考指数即为M个士兵的能力之和。随着时间的推移,指挥部将下达Q个指令来替换M个进行防守的士兵们,每个参加完防守任务的士兵由于疲惫等原因能力指数将下降1。现在士兵们排成一排,请你计算出每次进行防守的士兵原创 2014-04-27 19:51:46 · 1940 阅读 · 0 评论 -
HDU1166:敌兵布阵
Problem DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。原创 2013-01-22 15:12:28 · 14835 阅读 · 2 评论 -
HDU2871:Memory Control(线段树区间合并)
Problem DescriptionMemory units are numbered from 1 up to N.A sequence of memory units is called a memory block. The memory control system we consider now has four kinds of operations:1. Rese原创 2013-11-21 23:13:38 · 2721 阅读 · 0 评论 -
HDU4553:约会安排(线段树区间合并)
Problem Description 寒假来了,又到了小明和女神们约会的季节。 小明虽为屌丝级码农,但非常活跃,女神们常常在小明网上的大段发言后热情回复“呵呵”,所以,小明的最爱就是和女神们约会。与此同时,也有很多基友找他开黑,由于数量实在过于巨大,怎么安排时间便成了小明的一大心事。 我们已知小明一共有T的空闲时间,期间会有很多女神或者基友来找小明。 作为一个操作系统曾经原创 2013-11-14 23:22:30 · 3071 阅读 · 0 评论 -
HDU3397:Sequence operation(线段树区间合并)
Problem Descriptionlxhgww 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原创 2013-11-14 23:15:03 · 1897 阅读 · 1 评论 -
POJ3667:Hotel(线段树区间合并)
DescriptionThe cows are journeying north to Thunder Bay in Canada to gain cultural enrichment and enjoy a vacation on the sunny shores of Lake Superior. Bessie, ever the competent travel agent,原创 2013-11-14 23:03:40 · 2830 阅读 · 0 评论 -
HDU3308:LCIS(线段树区间合并)
Problem DescriptionGiven n integers.You have two operations:U A B: replace the Ath number by B. (index counting from 0)Q A B: output the length of the longest consecutive increasing subsequenc原创 2013-11-10 15:48:13 · 4459 阅读 · 3 评论 -
HDU4027:Can you answer these queries?(线段树单点更新)
Problem DescriptionA lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the battleships. Each of the battleships can be原创 2013-11-10 15:42:08 · 3391 阅读 · 1 评论 -
HDU3577:Fast Arrangement(线段树区间更新+lazy)
Problem DescriptionChinese always have the railway tickets problem because of its' huge amount of passangers and stations. Now goverment need you to develop a new tickets query system.One train ca原创 2013-11-07 20:29:13 · 2353 阅读 · 0 评论 -
POJ3067:Japan(线段树)
DescriptionJapan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for the venue. Japan is tall island with N cities on the East coast and M cities on the West coast (M <=原创 2014-05-13 01:23:34 · 2388 阅读 · 0 评论 -
HDU4893:Wow! Such Sequence!(线段树lazy)
Problem DescriptionRecently, Doge got a funny birthday present from his new friend, Protein Tiger from St. Beeze College. No, not cactuses. It's a mysterious blackbox.After some research, Doge原创 2014-07-30 16:55:34 · 1912 阅读 · 0 评论 -
HDU4638:Group(线段树离线处理)
Problem DescriptionThere are n men ,every man has an ID(1..n).their ID is unique. Whose ID is i and i-1 are friends, Whose ID is i and i+1 are friends. These n men stand in line. Now we select an原创 2015-07-14 12:14:15 · 1798 阅读 · 0 评论 -
XTU1238:Segment Tree(线段树)
Segment TreeProblem Description:A contest is not integrity without problems about data structure.There is an array a[1],a[2],…,a[n]. And q questions of the following 4 types:1 l r c - Up原创 2015-06-14 18:27:45 · 1821 阅读 · 0 评论 -
HDU4630:No Pain No Game(线段树)
Problem DescriptionLife is a game,and you lose it,so you suicide.But you can not kill yourself before you solve this problem:Given you a sequence of number a1, a2, ..., an.They are also a perm原创 2015-07-05 23:36:42 · 1613 阅读 · 0 评论 -
UVA11992:Fast Matrix Operations(线段树)
题意:有一个初始状态全为0的矩阵,一共有三个操作1 x1 y1 x2 y2 v:子矩阵(x1,y1,x2,y2)所有元素增加v2 x1 y1 x2 y2 v:子矩阵(x1,y1,x2,y2)所有元素设为v3 x1 y1 x2 y2 v:查询子矩阵(x1,y1,x2,y2)的元素和,最大值和最小值思路:因为总元素葛素不超过10^6,而且更新是对于连续的行进行更新,原创 2015-06-14 10:58:10 · 1664 阅读 · 0 评论 -
LA3938:"Ray, Pass me the dishes!"(线段树)
DescriptionAfter doing Ray a great favor to collect sticks for Ray, Poor Neal becomes very hungry. In return for Neal's help, Ray makes a great dinner for Neal. When it is time for dinner, Ray原创 2015-06-13 23:52:10 · 2450 阅读 · 0 评论 -
Codeforces35E:Parade(区间更新)
E. Paradetime limit per test4 secondsmemory limit per test64 megabytesinputinput.txtoutputoutput.txtNo Great Victory anniversary in Berland has ever passed with原创 2015-05-06 23:33:28 · 1488 阅读 · 0 评论 -
ZOJ3299:Fall the Brick(区间更新)
Now the God is very angry, so he wants to punish the lazy, greedy humans. He chooses to throw some lines of bricks (just down from the very high Heaven). These days the God lives in a 2D world, so h原创 2015-05-08 16:21:36 · 1358 阅读 · 0 评论 -
HDU4973:A simple simulation problem.(线段树)
Problem DescriptionThere are n types of cells in the lab, numbered from 1 to n. These cells are put in a queue, the i-th cell belongs to type i. Each time I can use mitogen to double the cells in原创 2014-08-26 13:51:35 · 1622 阅读 · 1 评论 -
HDU4902:Nice boat(线段树lazy)
Problem DescriptionThere is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the king used to be wise and beloved by his peop原创 2014-08-01 16:01:13 · 2234 阅读 · 0 评论 -
POJ1436:Horizontally Visible Segments(区间更新)
DescriptionThere is a number of disjoint vertical line segments in the plane. We say that two segments are horizontally visible if they can be connected by a horizontal line segment that does not ha原创 2013-11-07 20:18:19 · 2356 阅读 · 0 评论 -
POJ2991:Crane(线段树+几何)
DescriptionACM has bought a new crane (crane -- jeřáb) . The crane consists of n segments of various lengths, connected by flexible joints. The end of the i-th segment is joined to the beginning of原创 2013-11-19 18:33:41 · 4138 阅读 · 0 评论 -
HDU1394:Minimum Inversion Number
Problem DescriptionThe inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i aj.For a given sequence of numbers a1, a2, ..., an, if we move原创 2013-01-22 18:39:18 · 5307 阅读 · 0 评论 -
POJ2886:Who Gets the Most Candies?(线段树单点更新)
DescriptionN children are sitting in a circle to play a game.The children are numbered from 1 to N in clockwise order. Each of them has a card with a non-zero integer on it in his/her hand. The原创 2013-10-25 16:01:20 · 3848 阅读 · 1 评论 -
POJ2481:Cows(线段树单点更新)
DescriptionFarmer 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.Far原创 2013-10-27 15:31:54 · 2037 阅读 · 0 评论 -
HDU3564:Another LIS(线段树单点+LIS)
Problem DescriptionThere 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 sequence at a specific position. Now, we w原创 2013-10-26 18:24:32 · 2611 阅读 · 0 评论 -
HDU1556:Color the ball(线段树区间更新)
Problem DescriptionN个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a Input每个测试实例第一行为一个整数N,(N 当N = 0,输入结束。 Output每个测试实例输出一行,包括N个整数,第I个数代表第I个气球总共被涂色的次数。 Sample Input31 12 2原创 2013-10-26 15:16:44 · 4981 阅读 · 0 评论 -
POJ2182:Lost Cows(单点)
DescriptionN (2 <= N <= 8,000) cows have unique brands in the range 1..N. In a spectacular display of poor judgment, they visited the neighborhood 'watering hole' and drank a few too many beers befo原创 2013-10-25 15:16:11 · 3297 阅读 · 1 评论 -
POJ2828:Buy Tickets(线段树单点)
DescriptionRailway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue…The Lunar New Year was approaching, but unluckily the Little Ca原创 2013-10-24 17:01:22 · 6365 阅读 · 0 评论 -
HDU4399:Query
Problem DescriptionYou are given two strings s1[0..l1], s2[0..l2] and Q - number of queries.Your task is to answer next queries: 1) 1 a i c - you should set i-th character in a-th string to c;原创 2013-04-08 20:07:47 · 1524 阅读 · 0 评论 -
HDU1394:Minimum Inversion Number
Problem DescriptionThe inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i aj.For a given sequence of numbers a1, a2, ..., an, if we move原创 2013-04-06 18:00:28 · 1318 阅读 · 0 评论 -
HDU1166:敌兵布阵(线段树单点更新)
Problem DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。原创 2013-10-22 15:08:56 · 6318 阅读 · 0 评论 -
HDU3468:A Simple Problem with Integers(线段树区间更新+lazy)
DescriptionYou 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原创 2013-10-29 22:20:47 · 2121 阅读 · 0 评论 -
HDU1541:Stars(线段树单点更新)
Problem DescriptionAstronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars tha原创 2013-11-03 15:22:48 · 2504 阅读 · 0 评论 -
HDU1540:Tunnel Warfare(线段树区间合并)
Problem DescriptionDuring the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels la原创 2013-11-03 15:05:07 · 9073 阅读 · 2 评论 -
HDU4288:Coder(线段树单点更新版 && 暴力版)
Problem Description 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原创 2013-10-31 17:21:21 · 3173 阅读 · 2 评论 -
HDU1698:Just a Hook(线段树区间更新)
Problem DescriptionIn 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原创 2013-10-29 17:13:22 · 6149 阅读 · 6 评论 -
POJ2528:Mayor's posters(线段树区间更新+离散化)
DescriptionThe 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原创 2013-10-31 15:52:39 · 7678 阅读 · 6 评论 -
HDU2795:Billboard(线段树单点更新)
Problem DescriptionAt the entrance to the university, there is a huge rectangular billboard of size h*w (h is its height and w is its width). The board is the place where all possible announcements原创 2013-10-23 20:08:22 · 3625 阅读 · 0 评论