
图论-线段树
图论
Stephencurry‘s csdn
这个作者很懒,什么都没留下…
展开
-
A Simple Problem with Integers (POJ-3468)分块(线段树区间更新,区间求和)
You haveNintegers,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 to ask for the ...原创 2020-02-04 12:01:27 · 144 阅读 · 0 评论 -
I Hate It (HDU-1754)分块(单点更新,区间查询最值)
很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input 本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=200000,0<M<5000...原创 2020-02-04 10:54:47 · 275 阅读 · 0 评论 -
Successor (HDU-4366)分块(单点更新,区间查询最值,预处理,DFS序)
Sean owns a company and he is the BOSS.The other Staff has one Superior.every staff has a loyalty and ability.Some times Sean will fire one staff.Then one of the fired man’s Subordinates will replace ...原创 2020-02-03 11:22:00 · 371 阅读 · 0 评论 -
H - Points in Segments (cf:Points in Segments)
H - Points in Segments (cf:Points in Segments) You are given a set ofnnsegments on the axisOxOx, each segment has integer endpoints between11andmminclusive. Segments may intersect, overlap or ...原创 2019-03-29 19:36:53 · 245 阅读 · 0 评论 -
楼房重建 (BZOJ-2957)
楼房重建 (BZOJ-2957) 小A的楼房外有一大片施工工地,工地上有N栋待建的楼房。每天,这片工地上的房子拆了又建、建了又拆。他经常无聊地看着窗外发呆,数自己能够看到多少栋房子。 为了简化问题,我们考虑这些事件发生在一个二维平面上。小A在平面上(0,0)点的位置,第i栋楼房可以用一条连接(i,0)和(i,Hi)的线段表示,其中Hi为第i栋楼房的高度。如果这栋楼房上任何一个高度大于0的...原创 2019-05-16 16:27:13 · 358 阅读 · 0 评论 -
Japan(POJ-3067)
Japan(POJ-3067) Japan 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...原创 2019-05-17 20:42:59 · 523 阅读 · 0 评论 -
线段树辅助——扫描线法计算矩形面积并
线段树辅助——扫描线法计算矩形面积并 本篇文章转自:传送门 分析: 1.矩形比较多,坐标也很大,所以横坐标需要离散化(纵坐标不需要),熟悉离散化后这个步骤不难,所以这里不详细讲解了,不明白的还请百度 2.重点:扫描线法:假想有一条扫描线,从左往右(从右往左),或者从下往上(从上往下)扫描过整个多边形(或者说畸形。。多个矩形叠加后的那个图形)。如果是竖直方向上扫描,则是离散化横坐标,如果是水...转载 2019-05-18 08:48:09 · 984 阅读 · 0 评论 -
Atlantis (POJ-1151 (HDU-1542) )
Atlantis (POJ-1151 (HDU-1542) ) 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 unfort...原创 2019-05-18 10:51:09 · 487 阅读 · 0 评论 -
POJ1151 Atlantis(线段树,扫描线,离散化,矩形面积并)
转载自:传送门 题目: Atlantis Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 23220 Accepted: 8657 Description There are several ancient Greek texts that contain descriptions of the fabled isl...转载 2019-05-18 10:58:15 · 282 阅读 · 0 评论 -
线段树从零开始
线段树从零开始 本篇文章转自大神的博客:传送门 一:为什么需要线段树? 题目一: 10000个正整数,编号1到10000,用A[1],A[2],A[10000]表示。 修改:无 统计:1.编号从L到R的所有数之和为多少? 其中1<= L <=...转载 2019-05-08 19:52:00 · 263 阅读 · 0 评论 -
敌兵布阵 (HDU-1166)
敌兵布阵 (HDU-1166) C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。 中央情...原创 2019-05-09 20:43:05 · 451 阅读 · 0 评论 -
I Hate It (HDU-1754)
I Hate It (HDU-1754) 很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input 本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0<N&...原创 2019-05-10 11:40:50 · 298 阅读 · 0 评论 -
士兵杀敌(二)(NYOJ-116)
士兵杀敌(二)(NYOJ-116) 题目描述: 南将军手下有N个士兵,分别编号1到N,这些士兵的杀敌数都是已知的。 小工是南将军手下的军师,南将军经常想知道第m号到第n号士兵的总杀敌数,请你帮助小工来回答南将军吧。 南将军的某次询问之后士兵i可能又杀敌q人,之后南将军再询问的时候,需要考虑到新增的杀敌数。 输入描述: 只有一组测试数据 第一行是两个整数N,M,其中N表示士兵的个...原创 2019-05-13 19:47:48 · 262 阅读 · 0 评论 -
士兵杀敌(四)(NYOJ-123)
士兵杀敌(四)(NYOJ-123) 题目描述: 南将军麾下有百万精兵,现已知共有M个士兵,编号为1~M,每次有任务的时候,总会有一批编号连在一起人请战(编号相近的人经常在一块,相互之间比较熟悉),最终他们获得的军功,也将会平分到每个人身上,这样,有时候,计算他们中的哪一个人到底有多少军功就是一个比较困难的事情,军师小工的任务就是在南将军询问他某个人的军功的时候,快速的报出此人的军功,请你编写一...原创 2019-05-13 20:39:06 · 182 阅读 · 0 评论 -
Count the Colors (ZOJ-1610)
Count the Colors (ZOJ-1610) Painting 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 col...原创 2019-05-15 19:39:06 · 267 阅读 · 0 评论 -
Mayor's posters (POJ-2528)
Mayor's posters (POJ-2528) The 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. Th...原创 2019-05-15 20:52:50 · 305 阅读 · 0 评论 -
Posters (HDU-3265)
Posters (HDU-3265) Ted has a new house with a huge window. In this big summer, Ted decides to decorate the window with some posters to prevent the glare outside. All things that Ted can find are rect...原创 2019-05-24 20:26:17 · 316 阅读 · 0 评论 -
花神游历各国 (BZOJ-3211)
花神游历各国 (BZOJ-3211) Input Output 每次x=1时,每行一个整数,表示这次旅行的开心度 Sample Input 4 1 100 5 5 5 1 1 2 2 1 2 1 1 2 2 2 3 1 1 4 Sample Output 101 11 11 Hint 对于100%的数据, n ≤ 100000,m≤200000 ,data[...原创 2019-05-11 20:03:10 · 263 阅读 · 0 评论 -
Can you answer these queries? (HDU-4027)
Can you answer these queries? (HDU-4027) 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 th...原创 2019-05-11 17:46:49 · 394 阅读 · 0 评论 -
A Simple Problem with Integers (POJ-3468)
A Simple Problem with Integers (POJ-3468) You haveNintegers,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 g...原创 2019-05-10 16:04:47 · 302 阅读 · 0 评论 -
Just a Hook (HDU-1698)
Just a Hook (HDU-1698) 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 s...原创 2019-05-13 17:45:56 · 443 阅读 · 0 评论