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(思维)的更多相关文章

  1. HDU 2830 Matrix Swapping II (预处理的线性dp)

    Matrix Swapping II Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  2. 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 ...

  3. HDU 2830 Matrix Swapping II

    给一个矩阵,依然是求满足条件的最大子矩阵 不过题目中说任意两列可以交换,这是对题目的简化 求出h数组以后直接排序,然后找出(col-j)*h[j]的最大值即可(这里的j是从0开始) 因为排序会影响到h ...

  4. hdu 2830 Matrix Swapping II(额,,排序?)

    题意: N*M的矩阵,每个格中不是0就是1. 可以任意交换某两列.最后得到一个新矩阵. 问可以得到的最大的子矩形面积是多少(这个子矩形必须全是1). 思路: 先统计,a[i][j]记录从第i行第j列格 ...

  5. 【HDOJ】2830 Matrix Swapping II

    简单DP. /* 2830 */ #include <iostream> #include <string> #include <map> #include < ...

  6. Matrix Swapping II(求矩阵最大面积,dp)

    Matrix Swapping II Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  7. [HDOJ2830]Matrix Swapping II(胡搞)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2830 给一个矩阵只有0和1,矩阵的列可以和其他列交换无数次,问交换后整个矩阵形成的最大的全是1的子矩阵 ...

  8. [ An Ac a Day ^_^ ] hdu 2830 矩阵交换II

    第一眼觉得是个dp 但是有了可以随意交换的条件觉得简单了不少 但是还是没做出来…… 看了一下别人的做法才觉得自愧不如 因为所有列都可以随意交换 应该尽量把长的放在一起 那么将所有的矩形排序之后 以第j ...

  9. HDU 3081 Marriage Match II(二分法+最大流量)

    HDU 3081 Marriage Match II pid=3081" target="_blank" style="">题目链接 题意:n个 ...

随机推荐

  1. 在window系统下搭建基于ssh的git服务器

    以下是基于window server 2012搭建的,学习搭建过程需要很多问题,找了许多文章做了一下总结. 1.所需的软件 Git for Windows: MsysGit(Git-1.7.4-pre ...

  2. Chapter 1 First Sight——11

    I didn't relate well to people my age. 我没有向人们叙述清楚我的年龄 Maybe the truth was that I didn't relate well ...

  3. 将json转化为model

    /// <summary> /// 获取Json的Model /// </summary> /// <typeparam name="T">&l ...

  4. Linux查看文件夹大小du

    du命令参数详解见: http://baike.baidu.com/view/43913.htm 下面我们只对其做简单介绍: 查看linux文件目录的大小和文件夹包含的文件数   统计总数大小   d ...

  5. 数据的软删除-管理员的CRUD

    数据的“软删除”---把数据真正删除在某些时候会有问题.IsDeleted字段,false表示不删除,而是让用户可以看到,true表示是软删除,用户看不到. 一个表引用另外一张表的时候一定要引用主键. ...

  6. Net 自定义Excel模板导出数据

    转载自:http://www.cnblogs.com/jbps/p/3549671.html?utm_source=tuicool&utm_medium=referral 1 using Sy ...

  7. 原生 JS Ajax,GET和POST 请求实例代码

    javascript/js的ajax的GET请求代码如下所示: <script type="text/javascript"> /* 创建 XMLHttpRequest ...

  8. Swift中自定义打印方法

    // 1.获取打印所在的文件 let file = ( #file as NSString).lastPathComponent // 2.获取打印所在的方法 let funcName = #func ...

  9. HDU 4408 Minimum Spanning Tree 最小生成树计数

    Minimum Spanning Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  10. 1、下载LInux版的tomcat6

    1.下载LInux版的tomcat6 http://mirror.bit.edu.cn/apache/tomcat/tomcat-6/v6.0.37/bin/apache-tomcat-6.0.37. ...