
线段树
文章平均质量分 92
Viscu
勤能补拙。
展开
-
hdu1166 敌兵布阵
敌兵布阵Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 78356 Accepted Submission(s): 33102Problem Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Der原创 2016-09-01 00:45:14 · 729 阅读 · 0 评论 -
HDU 1394 Minimum Inversion Number 线段树
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...原创 2018-09-04 21:11:03 · 226 阅读 · 0 评论 -
HDU 2795 Billboard 线段树 java实现
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 announcem...原创 2018-09-04 23:36:51 · 260 阅读 · 0 评论 -
HDU 1166 敌兵布阵 线段树 java实现
Problem Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国...原创 2018-09-04 00:51:24 · 338 阅读 · 0 评论 -
POJ3468 A Simple Problem with Integers 线段树
Description You 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...原创 2018-09-15 19:20:09 · 257 阅读 · 0 评论 -
POJ2528 Mayor's posters 线段树+离散化
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. The city council has finall...原创 2018-09-16 00:46:38 · 319 阅读 · 0 评论 -
POJ 3225 区间 线段树
LogLoader是一家专门提供日志分析产品的公司。Ikki在做毕业设计的同时,还忙于在LogLoader做实习。在他的工作里,有一项是要写一个模块来处理时间区间。这个事情一直让他感到很迷糊,所以现在他很需要你帮忙。 在离散数学里面,你已经学习了几种基本的集合运算,具体地说就是并、交、相对补和对称差。它们自然地也适用于区间这种特殊的集合。作为你的快速参考,它们可以总结成下表: 运...原创 2018-09-16 21:51:05 · 302 阅读 · 0 评论 -
leetcode 315. 计算右侧小于当前元素的个数 离散化+线段树
给定一个整数数组 nums,按要求返回一个新数组 counts。数组 counts 有该性质: counts[i] 的值是 nums[i] 右侧小于 nums[i] 的元素的数量。 示例: 输入: [5,2,6,1] 输出: [2,1,1,0] 解释: 5 的右侧有 2 个更小的元素 (2 和 1). 2 的右侧仅有 1 个更小的元素 (1). ...原创 2018-09-11 00:44:58 · 546 阅读 · 0 评论 -
POJ 1151 Atlantis 线段树+离散化+扫描线 (java实现)
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 unfortunately, these ...原创 2018-09-13 17:32:03 · 636 阅读 · 0 评论 -
HDU 1698 Just a Hook 线段树 附带详细说明 java实现
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 w...原创 2018-09-04 18:24:01 · 235 阅读 · 0 评论 -
HDU 1754 I Hate It 线段树(java实现)
I Hate It 很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。简单题 涉及线段树单点更新 求区间最大 维护一个max数组即可。class Main{ public sta...原创 2018-09-04 17:05:53 · 369 阅读 · 0 评论 -
codevs3044 矩形面积求并(线段数+扫描线+离散化)
题目描述 Description输入n个矩形,求他们总共占地面积(也就是求一下面积的并)输入描述 Input Description可能有多组数据,读到n=0为止(不超过15组)每组数据第一行一个数n,表示矩形个数(n<=100)接下来n行每行4个实数x1,y1,x2,y1(0 <= x1 < x2 <= 100000;0 <= y1 < y2 <= 100000),表示矩形的左下角坐标和右上角坐标原创 2016-12-04 19:05:18 · 781 阅读 · 0 评论 -
BZOJ1067: [SCOI2007]降雨量 (RMQ或者线段树)
1067: [SCOI2007]降雨量Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 4026 Solved: 1067[Submit][Status][Discuss]Description 我们常常会说这样的话:“X年是自Y年以来降雨量最多的”。它的含义是X年的降雨量不超过Y年,且对于任意Y<Z<X,Z年的降雨量严格小于X年。例如200原创 2016-09-16 18:48:36 · 935 阅读 · 0 评论 -
1012: [JSOI2008]最大数maxnumber
现在请求你维护一个数列,要求提供以下两种操作:1、 查询操作。语法:Q L 功能:查询当前数列中末尾L 个数中的最大的数,并输出这个数的值。限制:L不超过当前数列的长度。2、 插入操作。语法:A n 功能:将n加上t,其中t是最近一次查询操作的答案(如果还未执行过查询操作,则t=0),并将所得结果对一个固定的常数D取模,将所得答案插入到数列的末尾。限制:n是非负整数并且在长整范围内。注意:初始时数原创 2016-09-06 01:50:39 · 1812 阅读 · 0 评论 -
HDU1698 Just a Hook(线段树成段替换)
Just a HookTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 28728 Accepted Submission(s): 14242Problem DescriptionIn the game of DotA, Pudg原创 2016-09-20 18:21:48 · 1126 阅读 · 0 评论 -
POJ3468 A Simple Problem with Integers
A Simple Problem with IntegersTime Limit: 5000MS Memory Limit: 131072KTotal Submissions: 97313 Accepted: 30386Case Time Limit: 2000MSDescriptionYou have N integers, A1, A2, ... , AN. Y原创 2016-09-20 20:53:40 · 1051 阅读 · 0 评论 -
线段数专题
基础篇:NYOJ 1185 最大最小值 传送门 描述 给出N个整数,执行M次询问。 对于每次询问,首先输入三个整数C、L、R: 如果C等于1,输出第L个数到第R个数之间的最小值; 如果C等于2,输出第L个数到第R个数之间的最大值; 如果C等于3,输出第L个数到第R个数之间的最小值与最大值的和。 (包括第L个数和第R个数)。 输入 首先输入一个整数T(T≤原创 2016-09-08 16:10:26 · 1393 阅读 · 0 评论 -
51NOD1287 加农炮(线段树)
一个长度为M的正整数数组A,表示从左向右的地形高度。测试一种加农炮,炮弹平行于地面从左向右飞行,高度为H,如果某处地形的高度大于等于炮弹飞行的高度H(A[i] >= H),炮弹会被挡住并落在i - 1处,则A[i - 1] + 1。如果H <= A[0],则这个炮弹无效,如果H > 所有的A[i],这个炮弹也无效。现在给定N个整数的数组B代表炮弹高度,计算出最后地形的样子。例如:地形高度A = {原创 2016-10-23 00:19:20 · 385 阅读 · 0 评论 -
HDU2795 Billboard(线段树)
BillboardTime Limit: 20000/8000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 20022 Accepted Submission(s): 8362Problem DescriptionAt the entrance to the unive原创 2016-10-22 20:22:59 · 269 阅读 · 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 the原创 2016-10-15 21:21:45 · 431 阅读 · 0 评论 -
leetcode218. 天际线问题 线段树+离散化
城市的天际线是从远处观看该城市中所有建筑物形成的轮廓的外部轮廓。现在,假设您获得了城市风光照片(图A)上显示的所有建筑物的位置和高度,请编写一个程序以输出由这些建筑物形成的天际线(图B)。 每个建筑物的几何信息用三元组 [Li,Ri,Hi] 表示,其中 Li 和 Ri 分别是第 i 座建筑物左右边缘的 x 坐标,Hi 是其高度。可以保证 0 ≤ Li, Ri ≤ INT_MAX...原创 2018-09-13 20:23:29 · 1446 阅读 · 0 评论