HDU 2830:Matrix Swapping II(思维)
http://acm.hdu.edu.cn/showproblem.php?pid=2830
题意:……
思路:对于每一列,它是固定的,用dp[][]处理出连续的长度。例如:
假设我们扫第四列的时候,我们可以知道 i = 4,j = 1这个位置是4,那么它上面是有3个连续的1,因此它的面积可以是4 * 1, i = 4, j = 2的时候,因为刚才左边肯定大于等于现在的值,那么目前的面积可以是3 * 2,以此类推。
图: 1 1 0 0 DP数组: 1 1 0 0 排序后: 1 1 0 0
0 1 1 1 0 2 1 1 2 1 1 0
1 1 1 1 1 3 2 2 3 2 2 1
0 1 1 0 0 4 3 0 4 3 0 0
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <stack>
using namespace std;
#define INF 0x3f3f3f3f
#define N 100010
typedef long long LL;
int dp[][];
char mp[][];
bool cmp(const int &a, const int &b) { return a > b; } int main() {
int n, m;
while(~scanf("%d%d", &n, &m)) {
for(int i = ; i <= n; i++) scanf("%s", + mp[i]);
memset(dp, , sizeof(dp));
for(int i = ; i <= n; i++)
for(int j = ; j <= m; j++)
if(mp[i][j] == '')
dp[i][j] = dp[i-][j] + ;
int ans = ;
for(int i = ; i <= n; i++) {
sort(dp[i] + , dp[i] + + m, cmp);
for(int j = ; j <= m; j++)
ans = max(ans, dp[i][j] * j);
}
printf("%d\n", ans);
}
return ;
}
HDU 2830:Matrix Swapping II(思维)的更多相关文章
- HDU 2830 Matrix Swapping II (预处理的线性dp)
Matrix Swapping II Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- HDu 2830 Matrix Swapping II(dp)
Problem Description Given an N * M matrix with each entry equal to 0 or 1. We can find some rectangl ...
- HDU 2830 Matrix Swapping II
给一个矩阵,依然是求满足条件的最大子矩阵 不过题目中说任意两列可以交换,这是对题目的简化 求出h数组以后直接排序,然后找出(col-j)*h[j]的最大值即可(这里的j是从0开始) 因为排序会影响到h ...
- hdu 2830 Matrix Swapping II(额,,排序?)
题意: N*M的矩阵,每个格中不是0就是1. 可以任意交换某两列.最后得到一个新矩阵. 问可以得到的最大的子矩形面积是多少(这个子矩形必须全是1). 思路: 先统计,a[i][j]记录从第i行第j列格 ...
- 【HDOJ】2830 Matrix Swapping II
简单DP. /* 2830 */ #include <iostream> #include <string> #include <map> #include < ...
- Matrix Swapping II(求矩阵最大面积,dp)
Matrix Swapping II Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- [HDOJ2830]Matrix Swapping II(胡搞)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2830 给一个矩阵只有0和1,矩阵的列可以和其他列交换无数次,问交换后整个矩阵形成的最大的全是1的子矩阵 ...
- [ An Ac a Day ^_^ ] hdu 2830 矩阵交换II
第一眼觉得是个dp 但是有了可以随意交换的条件觉得简单了不少 但是还是没做出来…… 看了一下别人的做法才觉得自愧不如 因为所有列都可以随意交换 应该尽量把长的放在一起 那么将所有的矩形排序之后 以第j ...
- HDU 3081 Marriage Match II(二分法+最大流量)
HDU 3081 Marriage Match II pid=3081" target="_blank" style="">题目链接 题意:n个 ...
随机推荐
- mysql 索引相关
引言: MYSQL由于其免费和开源的性质,在项目中用处广泛.大家都知道,一个MySQL数据库能够储存大量的数据,如果要在大量的数据中查找某一个数据,如果使用全表检索的话,即费时间又费力气,这时,就需要 ...
- PAT (Advanced Level) 1100. Mars Numbers (20)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- PHPstorm端口配置问题
- a java runtime environment(JRE) or java development kit(JDK) must be....
错误: 解决方法: 系统变量里设置下面: 变量名:JAVA_HOME 变量值:C:\Program Files\Java\jdk1.6.0_25 变量名:CLASSPATH 变量值:.;%JAVA_H ...
- memcache command
http://www.cnblogs.com/jeffwongishandsome/archive/2011/11/06/2238265.html
- js document
<html><head lang="en"> <meta charset="UTF-8"> <title>< ...
- (转) hadoop 一个Job多个MAP与REDUCE的执行
http://blog.csdn.net/chaoping315/article/details/6221440 在hadoop 中一个Job中可以按顺序运行多个mapper对数据进行前期的处理,再进 ...
- 挂载了Cinder Volume的实例无法动态迁移排错
现象:挂载了Cinder Volume的实例无法动态迁移 [root@node-5 nova]# tail -f compute.log 2016-01-13 16:36:12.870 18762 E ...
- 方便android开发网站:
可以通过输入包名或者Google Play地址消灾google市场的应用 http://apps.evozi.com/apk-downloader/ 16进制转常用的10进制 http://www.b ...
- PAT (Advanced Level) 1075. PAT Judge (25)
简单模拟题. 注意一点:如果一个人所有提交的代码都没编译通过,那么这个人不计排名. 如果一个人提交过的代码中有编译不通过的,也有通过的,那么那份编译不通过的记为0分. #include<cstd ...