简单DP。

 /* 2830 */
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std; const int maxn = ;
char M[maxn][maxn];
int mlen[maxn][maxn];
int cnt[maxn];
int n, m; int main() {
int i, j, k;
int ans, mx, tmp; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif while (scanf("%d %d", &n, &m) != EOF) {
for (i=; i<=n; ++i) {
scanf("%s", M[i]+);
for (j=; j<=m; ++j)
M[i][j] -= '';
}
for (j=; j<=m; ++j) {
mlen[j][] = ;
for (i=; i<=n; ++i) {
if (M[i][j])
mlen[j][i] = mlen[j][i-]+;
else
mlen[j][i] = ;
}
} ans = ;
for (i=; i<=n; ++i) {
memset(cnt, , sizeof(cnt));
mx = -;
for (j=; j<=m; ++j) {
++cnt[mlen[j][i]];
mx = max(mx, mlen[j][i]);
}
for (j=mx; j>; --j) {
ans = max(ans, cnt[j]*j);
cnt[j-] += cnt[j];
}
}
printf("%d\n", ans);
} #ifndef ONLINE_JUDGE
printf("time = %d.\n", (int)clock());
#endif return ;
}

【HDOJ】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. Matrix Swapping II(求矩阵最大面积,dp)

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

  6. 【SPOJ】Longest Common Substring II (后缀自动机)

    [SPOJ]Longest Common Substring II (后缀自动机) 题面 Vjudge 题意:求若干个串的最长公共子串 题解 对于某一个串构建\(SAM\) 每个串依次进行匹配 同时记 ...

  7. 【Python】 零碎知识积累 II

    [Python] 零碎知识积累 II ■ 函数的参数默认值在函数定义时确定并保存在内存中,调用函数时不会在内存中新开辟一块空间然后用参数默认值重新赋值,而是单纯地引用这个参数原来的地址.这就带来了一个 ...

  8. 【BZOJ3569】DZY Loves Chinese II

    [BZOJ3569]DZY Loves Chinese II 题面 bzoj 题目大意: 给你一张\(N(1\leq N\leq 10^5)\)个点\(M(1\leq M\leq 5\times 10 ...

  9. 【SPOJ】Longest Common Substring II

    [SPOJ]Longest Common Substring II 多个字符串求最长公共子串 还是将一个子串建SAM,其他字符串全部跑一边,记录每个点的最大贡献 由于是所有串,要对每个点每个字符串跑完 ...

随机推荐

  1. 解锁Scott过程中出现的问题及解决办法

    一.conn sys/sys as sysdba; //以DBA的身份登录 出现以下错误 经查 协议适配器错误的问题的原因有三个 监听服务没有起起来.windows平台个一如下操作:开始---程序-- ...

  2. ASP.NET获取汉字首字母

    /// <summary> /// 获取汉字首字母(可包含多个汉字) /// </summary> /// <param name="strText" ...

  3. 如何使用Git上传项目代码到代码服务器

    如你本机新建Git项目 地址:git@github.com:yourName/yourRepo.git,远程代码库服务器地址:192.168.10.1,远程代码服务器账户名密码:admin 密码:12 ...

  4. XPath操作XML文档

    NET框架下的Sytem.Xml.XPath命名空间提供了一系列的类,允许应用XPath数据模式查询和展示XML文档数据. 3.1XPath介绍 主要的目的是在xml1.0和1.1文档节点树种定位节点 ...

  5. H TML5 之 (4) 小项目一 时钟

    这里做一个HTML5 入门的练手,一个小时钟项目,可以再上面拓展很多,程序员培养的就是思想 <!DOCTYPE HTML> <html> <head> <ti ...

  6. android自定义样式大全:shape,selector,layer-list,style,动画全部内容

    原文:http://keeganlee.me/post/android/20150830 以下摘取了部分内容: shape 一般用shape定义的xml文件存放在drawable目录下,若项目没有该目 ...

  7. (六)Struts2 国际化

    所有的学习我们必须先搭建好Struts2的环境(1.导入对应的jar包,2.web.xml,3.struts.xml) 第一节:国际化简介 国际化(Internationlization),通俗地讲, ...

  8. why slow thinking wins

    今天Hacker News上的一篇文章<为什么想得慢的人能赢>引起了广泛的讨论. 网友Scott Burson在文章后评论说:"之前,我雇佣了一位TopCoder冠军,原本预计他 ...

  9. string的一些更改发

    /* String 类:  1.1字符串的长度    int c =对象.length();  1.2字符串某个字符的位置  int index=对象.indexOf("字母")  ...

  10. leetcode中一些要用到动态规划的题目

    需要仔细回顾的题目: 1.Interleaving String   交叉存取字符串 2.Decode Ways   字符串解码 3.Subsets   Subsets II          求一个 ...