POJ 2559 Largest Rectangle in a Histogram】的更多相关文章

[POJ 2559]Largest Rectangle in a Histogram Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left s…
// poj 2559 Largest Rectangle in a Histogram 栈 // // n个矩形排在一块,不同的高度,让你求最大的矩形的面积(矩形紧挨在一起) // // 这道题用的是数据结构做.也能够递推做.眼下仅仅会数据结构的 // // 对于每一个高度h,求一个左边界L和右边界R,分别表示的意义是 // L是下标为j的矩形的高度的hj小于当前h的最大的j的值. 则依据定义 // 我们能够知道j到i之间的h都是大于当前的hi的. // R是下标为k的矩形的高度的hk大于当前…
题目传送门 /* 题意:宽度为1,高度不等,求最大矩形面积 stack(数组模拟):对于每个a[i]有L[i],R[i]坐标位置 表示a[L[i]] < a[i] < a[R[i]] 的极限情况 st[]里是严格单调递增,若不记录的话还要O(n)的去查找L,R,用栈的话降低复杂度 */ #include <cstdio> #include <cstring> #include <algorithm> #include <stack> #inclu…
http://poj.org/problem?id=2559 Largest Rectangle in a Histogram Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12297   Accepted: 3974 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base lin…
题目地址:http://poj.org/problem?id=2559 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left shows th…
Largest Rectangle in a Histogram Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19782   Accepted: 6393 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal wi…
传送门 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left shows the histogram that consists of rec…
Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18942   Accepted: 6083 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heigh…
Largest Rectangle in a Histogram Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15831   Accepted: 5121 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal wi…
Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left shows the histogram that consists of rectang…
[题目链接] http://poj.org/problem?id=2559 [题目大意] 给出一些宽度为1的长方形下段对其后横向排列得到的图形,现在给你他们的高度, 求里面包含的最大长方形的面积 [题解] 我们枚举每个位置的最大高度全部被保留时得到的最优解,那么答案一定被包含在其中, 那么题目转化为求出每个高度左右两边最近的比其低的位置,可以用单调栈完成. [代码] #include <cstdio> #include <algorithm> using namespace std…
嗯... 题目链接:http://poj.org/problem?id=2559 一.单调栈: 1.性质: 单调栈是一种特殊的栈,特殊之处在于栈内的元素都保持一个单调性,可能为单调递增,也可能为单调递减. 2.模样: 这是一个单调递增的栈,如果我们插入的元素大于栈顶元素,则直接入栈: 如果我们插入的元素小于栈顶,则需要把栈内所有大于它的元素暂时出栈,将这个元素入栈后,再将暂时出栈的元素入栈,维护单调性. 二.模板: 这道题是单调栈的一道模板题: 先思考一个问题,如果题目中的矩形的高度都是单调递增…
[题目分析] 本来是单调栈的题目,用笛卡尔树可以快速的水过去. 把每一个矩阵看成一个二元组(出现的顺序,高度). 然后建造笛卡尔树. 神奇的发现,每一个节点的高度*该子树的大小,就是这一块最大的子矩阵的可能解. 用二元组的第一个下标来限制,使它们在一块儿,然后堆的性质又限制了宽度以及高度. 计算,取最值即可. [代码] #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath&g…
http://acm.hdu.edu.cn/showproblem.php?pid=1506  || http://poj.org/problem?id=2559 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 19316    Accepted Submission(s): 5829 Problem Description A hist…
Largest Rectangle in a Histogram Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 26549   Accepted: 8581 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal wi…
题目大意:原题链接 一排紧密相连的矩形,求能构成的最大矩形面积. 为了防止栈为空,所以提前加入元素(-1,0) #include<cstdio> #include<stack> #define maxn 100005 using namespace std; long long h[maxn]; struct Element { long long height; int startpos; Element(){} Element(long long _h,int _p){ hei…
题目链接:http://poj.org/problem?id=2559 Largest Rectangle in a Histogram Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 24259   Accepted: 7844 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common bas…
Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left shows the histogram that consists of rectang…
Largest Rectangle in a Histogram http://poj.org/problem?id=2559 题意:给出若干宽度相同的矩形的高度(条形统计图),求最大子矩形面积 解题思路 单调栈的经典题(嫌弃字多可以先看后面的示例再来看这个思路) 显然,最终的子矩形高度一定和某一个矩形相等(反证).因此一个暴力的做法就是枚举每一个矩形,然后往两边扩散.在它左侧找到第一个高度比它小的,右侧也一样.则可以求出最大可扩散宽度,乘上高度即可以更新答案.复杂度O(n2) 如果说要优化刚才…
Largest Rectangle in a Histogram 题目链接(点击)来源poj 2559 A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left show…
Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left shows the histogram that consists of rectang…
Largest Rectangle in a Histogram Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 16   Accepted Submission(s) : 6 Problem Description A histogram is a polygon composed of a sequence of rectangles…
Largest Rectangle in a Histogram HDU1506 一道DP题: 思路:http://blog.csdn.net/qiqijianglu/article/details/8556852 #include <stdio.h> #include <iostream> using namespace std; ]; ],r[]; int main() { int n,i,j; long long maxx,sum; while(~scanf("%d…
2107: Largest Rectangle in a Histogram Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 777  Solved: 220 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may ha…
E - Largest Rectangle in a Histogram Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1506 Appoint description: Description A histogram is a polygon composed of a sequence of rectangles aligned a…
Largest Rectangle in a Histogram Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11541    Accepted Submission(s): 3174 Problem Description A histogram is a polygon composed of a sequence of rect…
Largest Rectangle in a Histogram Problem Description: A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left sh…
Largest Rectangle in a Histogram Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11706    Accepted Submission(s): 3219 Problem Description A histogram is a polygon composed of a sequence of rec…
Largest Rectangle in a Histogram Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 15189    Accepted Submission(s): 4408 Problem Description A histogram is a polygon composed of a sequence of rect…