描述

就不需要描述了...

题目传送门

题解

被lyd的书的标签给骗了(居然写了单调队列优化dp??)  看了半天没看出来哪里是单调队列dp,表示强烈谴责QAQ

w x y z  可以各自 变成a ,b c 中的几种, 那么只需要考虑矩阵由 a, b 或 c 构成就可以了。

对于每一种情况都枚举一次, 比如现在考虑由 a 构成的矩阵, 只需要将能 w y z a 的位置记为 1, 其他位置记为 0 ,然后找面积最大的 由 1 组成的矩阵即可。

那么这题就是道 单调栈裸题了  (   不会的同学可以去这边学

代码

我的单调栈好像有点丑。。。

 #include<cstring>
#include<algorithm>
#include<cstdio>
#include<stack>
#define rd read()
#define rep(i,a,b) for( int i = (a); i <= (b); ++i )
#define per(i,a,b) for( int i = (a); i >= (b); --i )
using namespace std; const int N = 1e3 + ; char s[N][N]; int n, m, mp[N][N], ans, h[N], pre[N], nxt[N]; stack<int> st; void cal() {
memset(h, , sizeof(h));
rep( i, , n ) {
rep( j, , m )
if( mp[i][j] ) h[j]++;
else h[j] = ;
while( st.size() ) st.pop();
rep( j, , m ) {
int pr = ;
while( !st.empty() ) {
pr = st.top();
if( h[pr] >= h[j] ) st.pop();
else break;
}
st.push(j);
pre[j] = pr;
} while( st.size() ) st.pop();
per( j, m, ) {
int nt = m + ;
while( !st.empty() ) {
nt = st.top();
if( h[nt] >= h[j] ) st.pop();
else break;
}
st.push(j);
nxt[j] = nt;
}
rep( j, , m ) {
int len = nxt[j] - pre[j] - ;
ans = max( ans, len * h[j] );
}
}
} int main()
{
while( scanf("%d%d",&n,&m) == ) {
ans = ;
rep( i, , n ) scanf("%s",s[i] + );
rep( i, , n ) rep( j, , m ) {
if( s[i][j] == 'w' || s[i][j] == 'y' || s[i][j] == 'z' || s[i][j] == 'a' ) mp[i][j] = ;
else mp[i][j] = ;
}
cal();
rep( i, , n ) rep( j, , m ) {
if( s[i][j] == 'w' || s[i][j] == 'x' || s[i][j] == 'z' || s[i][j] == 'b' ) mp[i][j] = ;
else mp[i][j] = ;
}
cal();
rep( i, , n ) rep( j, , m ) {
if( s[i][j] == 'x' || s[i][j] == 'y' || s[i][j] == 'z' || s[i][j] == 'c' ) mp[i][j] = ;
else mp[i][j] = ;
}
cal();
printf("%d\n", ans);
}
return ;
}

hdu2870 Largest Submatrix 单调栈的更多相关文章

  1. HDU 2870 Largest Submatrix (单调栈)

    http://acm.hdu.edu.cn/showproblem.php? pid=2870 Largest Submatrix Time Limit: 2000/1000 MS (Java/Oth ...

  2. HDU2870 Largest Submatrix

    Largest Submatrix Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  3. poj 2559 Largest Rectangle(单调栈)

    Largest Rectangle in a Histogram Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 26549 ...

  4. POJ-3494 Largest Submatrix of All 1’s (单调栈)

    Largest Submatrix of All 1’s Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 8551   Ac ...

  5. Largest Submatrix of All 1’s(思维+单调栈)

    Given a m-by-n (0,1)-matrix, of all its submatrices of all 1's which is the largest? By largest we m ...

  6. POJ 3494 Largest Submatrix of All 1’s 单调队列||单调栈

    POJ 3494 Largest Submatrix of All 1’s Description Given a m-by-n (0,1)-matrix, of all its submatrice ...

  7. [POJ2559&POJ3494] Largest Rectangle in a Histogram&Largest Submatrix of All 1’s 「单调栈」

    Largest Rectangle in a Histogram http://poj.org/problem?id=2559 题意:给出若干宽度相同的矩形的高度(条形统计图),求最大子矩形面积 解题 ...

  8. POJ - 3494 Largest Submatrix of All 1’s 单调栈求最大子矩阵

    Largest Submatrix of All 1’s Given a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is ...

  9. SPOJ MINSUB - Largest Submatrix(二分+单调栈)

    http://www.spoj.com/problems/MINSUB/en/ 题意:给出一个n*m的矩阵M,和一个面积k,要使得M的子矩阵M'的最小元素最大并且面积大于等于k,问子矩阵M'的最小元素 ...

随机推荐

  1. 微服务之间的调用(Ribbon与Feign)

    来源:https://blog.csdn.net/jrn1012/article/details/77837658 使用Eureka作为服务注册中心,在服务启动后,各个微服务会将自己注册到Eureka ...

  2. requests库的文档--快速上手

    快速上手 迫不及待了吗?本页内容为如何入门 Requests 提供了很好的指引.其假设你已经安装了 Requests.如果还没有,去安装一节看看吧. 首先,确认一下: Requests 已安装 Req ...

  3. mui-当使用addeleventlisener()方法绑定事件时选择器无法绑定事件

    在mui中绑定事件不能用jQuery或mui(“#XX”)的形式选取某个元素,而是document.getelementbyid()的形式 mui(“#XX”)可以使用on方法绑定事件

  4. JUC(java.util.concurrent)

    在 Java 5.0 提供了 java.util.concurrent (简称JUC )包,在此包中增加了在并发编程中很常用的实用工具类,用于定义类似于线程的自定义子系统,包括线程池.异步 IO 和轻 ...

  5. kangle web配置phpmyadmin

    1. kangle安装参考:https://www.kangleweb.com/thread-6001-1-1.html 2. 安装mysql-5.7.22:http://www.cnblogs.co ...

  6. burpsuite的使用(三)

    send to repeater 手动提交,注入. 将post请求改成get请求 直接就可以看到页面 生成csrf POC代码 点击在浏览器中测试,copy 拿到浏览器里访问 或者拷贝出来 保存到文本 ...

  7. [疯狂Java]JDBC:PreparedStatement预编译执行SQL语句

    1. SQL语句的执行过程——Statement直接执行的弊病: 1) SQL语句和编程语言一样,仅仅就会普通的文本字符串,首先数据库引擎无法识别这种文本字符串,而底层的CPU更不理解这些文本字符串( ...

  8. Hadoop详细安装步骤

    hadoop安装:(分布式模式)参考地址:http://dblab.xmu.edu.cn/blog/install-hadoop/ http://dblab.xmu.edu.cn/blog/insta ...

  9. 取消掉maven

  10. GitHub优秀项目

    https://blog.csdn.net/javaxuexi123/article/details/79248124