线段树
线段树
浪漫些许潦草
这个作者很懒,什么都没留下…
展开
-
hdu 1540 Tunnel Warfare(线段树——单点更新+区间合并)
Tunnel WarfareProblem Description During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected原创 2017-04-28 15:53:58 · 444 阅读 · 0 评论 -
hdu 4578 Transformation(线段树+多种操作)
TransformationProblem DescriptionYuanfang is puzzled with the question below: There are n integers, a1, a2, …, an. The initial values of them are 0. There are four kinds of operations. Operation 1:原创 2017-08-01 18:01:48 · 559 阅读 · 2 评论 -
UESTC - 1597 An easy problem C (线段树)
An easy problem CN个数排成一列,有三种操作。1.给一段区间内的每个数乘上一个非负整数。2.给一段区间内的每个数加上一个非负整数.3.询问一段区间的和模上P的值。Input第一行两个整数N(1≤N≤100000)表示数的个数,P(1≤P≤1000000000)表示模的值。接下来一行N个整数ai(0≤ai≤1000000000),接下来一行一个整数M(1≤M≤100000)表示操作数量原创 2017-08-01 18:58:45 · 378 阅读 · 0 评论 -
bzoj 4627 回转寿司(权值线段树)
回转寿司Description酷爱日料的小Z经常光顾学校东门外的回转寿司店。在这里,一盘盘寿司通过传送带依次呈现在小Z眼前。不同的寿 司带给小Z的味觉感受是不一样的,我们定义小Z对每盘寿司都有一个满意度,例如小Z酷爱三文鱼,他对一盘三文 鱼寿司的满意度为10;小Z觉得金枪鱼没有什么味道,他对一盘金枪鱼寿司的满意度只有5;小Z最近看了电影“美 人鱼”,被里面的八爪鱼恶心到了,所以他对一盘八爪鱼刺原创 2017-08-10 19:28:24 · 1048 阅读 · 0 评论 -
hdu 6070 Dirt Ratio(二分+线段树)(2017 Multi-University Training Contest - Team 4 )
Dirt Ratio题目链接:Dirt Ratio题意:x为区间数字的种数,y为区间长度,求x/y的最小值。官方题解: size(l,r)r−l+1<=mid\frac{size(l,r)}{r-l+1}<=mid转化为size(l,r)+mid∗l<=mid∗(r+1)size(l,r)+mid*l<=mid*(r+1)是关键性的一步。转化后我们就可以通过线段树来维护size(l,r)+mid∗原创 2017-08-04 12:21:54 · 495 阅读 · 0 评论 -
hdu 1166 敌兵布阵(基础树状数组)(基础线段树--单点更新)
敌兵布阵Problem Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监原创 2017-04-12 21:53:09 · 412 阅读 · 0 评论 -
玲珑杯 1117 - RE:从零开始的异世界生活(线段树)
从零开始的异世界生活题目链接:从零开始的异世界生活题意: 给一个集合,最开始为空(不是数学上的集合) 五个操作:1、插入x 2、把小于x的数变成x 3、把大于x的数变成x 4、求集合中第x小数 5、求集合中小于x的数个数思路:先将除了操作4以外的数离散化,然后建立线段树 对于操作1,插入x,直接将对应x的节点加1 对于操作2,先查询小于x的有多少个数k,然后将区间[1,x-1]全部置原创 2017-08-05 17:15:36 · 474 阅读 · 0 评论 -
ZOJ 1610 Count the Colors(线段树——区间更新)(成段染色)
Count the ColorsPainting some colored segments on a line, some previously painted segments may be covered by some the subsequent ones. Your task is counting the segments of different colors you can se原创 2017-04-24 15:21:08 · 609 阅读 · 0 评论 -
hdu 4027 Can you answer these queries?(线段树——区间更新)(思路)
Can you answer these queries?Problem Description A 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. Eac原创 2017-04-24 21:51:49 · 767 阅读 · 0 评论 -
hdu 1542 Atlantis(线段树+扫描线——面积并)
AtlantisProblem Description There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some of these texts even include maps of parts of the island. But unfortunate原创 2017-05-04 20:07:16 · 754 阅读 · 0 评论 -
BZOJ 2957 楼房重建(线段树)(思路)
楼房重建Description 小A的楼房外有一大片施工工地,工地上有N栋待建的楼房。每天,这片工地上的房子拆了又建、建了又拆。他经常无聊地看着窗外发呆,数自己能够看到多少栋房子。 为了简化问题,我们考虑这些事件发生在一个二维平面上。小A在平面上(0,0)点的位置,第i栋楼房可以用一条连接(i,0)和(i,Hi)的线段表示,其中Hi为第i栋楼房的高度。如果这栋楼房上任何一个高度大于0的点与(原创 2017-07-08 17:00:01 · 905 阅读 · 0 评论 -
nyoj 盖伦的告白(线段树||双端队列)
盖伦的告白题目描述 盖伦和赵信这对基友又在打赌,谁输了就去向卡特琳娜告白。。这一季中盖伦一如既往的怂。赵信为了帮他一把,故意表现出很厉害的样子,结果成功激活了盖伦的智商。赵信手中有n张牌,每张牌上面有一个数,这些牌是非递减的。现在盖伦从他手中抽取k张牌,如果盖伦抽取后剩下的牌中相邻两张的差值的最大值最小,就算他赢。结果当然是盖伦赢了。那么问题来了!输入 第一行两个正整数n和k。第二行n个数代表n原创 2017-07-29 18:53:49 · 473 阅读 · 0 评论 -
hdu 1828(poj 1177)Picture(线段树+扫描线)(轮廓线)
PictureProblem Description A number of rectangular posters, photographs and other pictures of the same shape are pasted on a wall. Their sides are all vertical or horizontal. Each rectangle can be par原创 2017-06-14 12:26:44 · 434 阅读 · 0 评论 -
hdu 3974 Assign the task(区间建树)(区间更新+单点查询)
Assign the taskProblem Description There is a company that has N employees(numbered from 1 to N),every employee in the company has a immediate boss (except for the leader of whole company).If you are原创 2017-05-01 20:52:18 · 538 阅读 · 0 评论 -
hdu 1754 I Hate It (线段树--求区间最大值)(基础)
I Hate ItProblem Description 很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input 本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0<N<原创 2017-04-20 08:45:20 · 437 阅读 · 0 评论 -
poj 3468 A Simple Problem with Integers(线段树——区间更新)
A Simple Problem with IntegersDescriptionYou 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原创 2017-04-20 21:41:13 · 315 阅读 · 0 评论 -
hdu 1698 Just a Hook(线段树——区间更新)
Just a HookProblem Description 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 o原创 2017-04-21 16:51:53 · 412 阅读 · 0 评论 -
poj 3264 Balanced Lineup(基础线段树)
Balanced LineupDescriptionFor the daily milking, Farmer John’s N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of原创 2017-04-21 18:25:02 · 367 阅读 · 0 评论 -
poj 2528 Mayor's posters(线段树+离散化)
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. The c原创 2017-04-22 19:52:55 · 473 阅读 · 0 评论 -
CodeForces - 668D Little Artem and Time Machine(线段树||树状数组)
Little Artem and Time MachineLittle Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply this time machine to a w原创 2017-05-05 14:12:52 · 586 阅读 · 0 评论 -
hdu 1255 覆盖的面积(线段树+扫描线——面积交)
Problem Description 给定平面上若干矩形,求出被这些矩形覆盖过至少两次的区域的面积. Input 输入数据的第一行是一个正整数T(1<=T<=100),代表测试数据的数量.每个测试数据的第一行是一个正整数N(1<=N<=1000),代表矩形的数量,然后是N行数据,每一行包含四个浮点数,代表平面上的一个矩形的左上角坐标和右下角坐标,矩形的上下边和X轴平行,左右边和Y轴平行.坐标原创 2017-05-20 17:06:39 · 526 阅读 · 0 评论 -
hdu 4614 Vases and Flowers(线段树+二分)
Vases and FlowersProblem Description 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 i原创 2017-07-10 16:54:36 · 925 阅读 · 0 评论 -
nyoj 2361 流星雨(线段树)
2361: 流星雨题目链接:流星雨原创 2017-09-28 13:06:59 · 393 阅读 · 0 评论