题目:统计一个字母矩阵中最大的相同字母的面积,有些字母可以换成其他字母。
分析:dp,单调队列。计算分三种分别换成a,b,c求出最大的子矩阵,求出最大即可。
然后就是单调队列优化的查询算法了,确定每个点右(左)边第一个比他小的点;
T(N)=O(N^2)。
说明:(2011-09-19 08:15)。
#include
#include...
分类:
其他好文 时间:
2014-09-22 09:22:42
阅读次数:
206
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.难度:90 这是一道非常综合的题目,要求在0-1矩阵中找出面积最大...
分类:
其他好文 时间:
2014-09-22 07:45:22
阅读次数:
189
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist...
分类:
其他好文 时间:
2014-09-22 02:12:11
阅读次数:
245
题目:给你一些不同高度的宽度为1的木板,问能截取最大矩形面积。
分析:dp,单调队列。关键在于找到每个高度的最大连续长度,最大面积了 O(N*max(L),R));
如果暴力的话,则代价为O(N),则总代价为O(N*N)无法处理100000数据量;
但是可用单调队列,做预处理 用O(N)时间计算出所有点的边界,此时时间复杂度为 O(N);...
分类:
其他好文 时间:
2014-09-21 23:23:01
阅读次数:
247
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[?2,1,?3,4,?1,2,1,...
分类:
其他好文 时间:
2014-09-15 15:46:19
阅读次数:
183
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [?2,1,?3,4,?1,2,1...
分类:
其他好文 时间:
2014-09-12 14:45:53
阅读次数:
213
Maximal RectangleGiven a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.解题分析:联想到 最大矩形面积 ...
分类:
其他好文 时间:
2014-09-11 20:56:02
阅读次数:
270
Largest Rectangle in HistogramGiven n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of...
分类:
其他好文 时间:
2014-09-11 20:52:42
阅读次数:
323
点击打开链接
有向图
把强联通分量缩点后得到一个DAG,然后DP。
#include
#include
#include
#include
#include
#include
using namespace std;
const int maxn = 1000 + 10;
vector G[maxn];
int dfn[maxn], low[maxn], sccno...
分类:
其他好文 时间:
2014-09-11 11:13:41
阅读次数:
159
题目链接:POJ 2559 Largest Rectangle in a Histogram
题目链接:HDU 1506 Largest Rectangle in a Histogram
题意:给出一串序列表示对应矩形的高度,求整个图中最大的矩形区域。
2, 1, 4, 5, 1, 3, 3
如图所示:
思路:每个矩形向左向右最大能扩张到的长度乘上他的高度,...
分类:
其他好文 时间:
2014-09-09 16:08:58
阅读次数:
188