线段树
BYSora
这个作者很懒,什么都没留下…
展开
-
poj3468——A Simple Problem with Integers(线段树,区间更新)
Description 给出了一个序列,你需要处理如下两种询问。“C a b c”表示给[a, b]区间中的值全部增加c (-10000 ≤ c ≤ 10000)。“Q a b” 询问[a, b]区间中所有值的和。Input 第一行包含两个整数N, Q。1 ≤ N,Q ≤ 100000.第二行包含n个整数,表示初始的序列A (-1000000000 ≤ Ai ≤ 1000000000)。接下来Q原创 2016-04-27 20:13:10 · 764 阅读 · 0 评论 -
Lightoj1112——Curious Robin Hood(线段树+单点更新)
Robin Hood likes to loot rich people since he helps the poor people with this money. Instead of keeping all the money together he does another trick. He keeps n sacks where he keeps this money. The sac原创 2017-04-13 21:33:01 · 687 阅读 · 0 评论 -
蓝桥杯算法提高——上帝造题五分钟(线段树+区间最小值)
问题描述 第一分钟,上帝说:要有题。于是就有了L,Y,M,C 第二分钟,LYC说:要有向量。于是就有了长度为n写满随机整数的向量 第三分钟,YUHCH说:要有查询。于是就有了Q个查询,查询向量的一段区间内元素的最小值 第四分钟,MZC说:要有限。于是就有了数据范围 第五分钟,CS说:要有做题的。说完众神一哄而散,留你来收拾此题 输入格式 第一行两个正整数n和Q,原创 2017-04-03 18:43:50 · 774 阅读 · 0 评论 -
蓝桥杯算法训练——操作格子(线段树+单点更新+区间求和+求最大值)
问题描述 有n个格子,从左到右放成一排,编号为1-n。共有m次操作,有3种操作类型:1.修改一个格子的权值,2.求连续一段格子权值和,3.求连续一段格子的最大值。对于每个2、3操作输出你所求出的结果。输入格式 第一行2个整数n,m。接下来一行n个整数表示n个格子的初始权值。接下来m行,每行3个整数p,x,y,p表示操作类型,p=1时表示修改格子x的权值为y,p=2时表示求区间[x,y]内格子权值原创 2017-03-03 21:32:34 · 792 阅读 · 0 评论 -
hdu4027——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. Each of the battleships can be m原创 2016-09-16 19:12:05 · 967 阅读 · 0 评论 -
poj3264——Balanced Lineup(线段树+区间最大值与最小值)
DescriptionFor 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 the cows. To ke原创 2016-09-14 20:07:55 · 1062 阅读 · 0 评论 -
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 Cat still原创 2016-09-14 19:25:30 · 1015 阅读 · 0 评论 -
hdu1698——Just a Hook(线段树+区间更新)
Problem 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 of the same原创 2016-09-12 21:07:01 · 828 阅读 · 0 评论 -
hdu2795——Billboard(线段树+区间最大值)
Problem Description At 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 a原创 2016-09-12 19:46:41 · 729 阅读 · 0 评论 -
Lightoj1082——Array Queries(线段树+求区间最小值)
Given an array with N elements, indexed from 1 to N. Now you will be given some queries in the form I J, your task is to find the minimum value from index I to J.Input Input starts with an integer T (原创 2016-09-12 12:31:42 · 722 阅读 · 0 评论 -
HDU1166——敌兵布阵(线段树)
DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。 中央情报原创 2015-11-12 19:02:16 · 703 阅读 · 0 评论 -
山东省第五届ACM省赛题——Devour Magic(线段树区间覆盖+更新)
题目描述 In Warcraft III, Destroyer is a large flying unit that must consume magic to sustain its mana. Breaking free of the obsidian stone that holds them, these monstrous creatures roar into battle, swa原创 2016-05-28 14:01:29 · 1182 阅读 · 0 评论 -
hdu1754——I Hate It(线段树,单点更新,求最大值)
Problem Description很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input本题目包含多组测试,请处理到文件结束。在每个测试的第一行,有两个正整数 N原创 2016-04-27 20:26:06 · 613 阅读 · 0 评论 -
hdu1394——Minimum Inversion Number(线段树求逆序数)
Problem Description 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 we mo原创 2016-04-28 09:22:12 · 730 阅读 · 0 评论 -
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 has原创 2017-05-03 09:46:06 · 1151 阅读 · 0 评论