HDU 2830 Matrix Swapping II
来源:互联网 发布:钢铁力量 半人马 数据 编辑:程序博客网 时间:2024/05/21 08:06
这个题好像让我钻空子了。 也是求 完全是 1的子矩阵的 1的最多的个数。
方法还是 对于每一个 是 1 的位置。 先求出竖直方向连接的1的个数,然后对于每一行 非 0的排序 乘就好了。
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <string>#include <algorithm>#include <fstream>#include <set>#include <map>#include <queue>#include <stack>#include <list>#include <vector>#include <cmath>#include <iomanip>#include <cmath>typedef long long LL;typedef unsigned long long LLU;const double PI=acos(-1.0);using namespace std;#define MAXN 1000+10#define INF 1 << 30char s[MAXN][MAXN],d[MAXN][MAXN];int q[MAXN][MAXN];int main (){ int m,n; while(scanf("%d%d",&m,&n) != EOF){ for(int i = 1; i <= m; i++){ scanf("%s",s[i]+1); } memset(q,0,sizeof(q)); memset(d,0,sizeof(d)); for(int i = 1; i <= m; i++){ for(int j = 1; j <= n; j++){ if(s[i][j] == '0') q[i][j] = 0; else q[i][j] = 1; } } for(int i = 1; i <= m; i++){ for(int j = 1; j <= n; j++){ if(q[i][j]) d[i][j] = d[i-1][j] + 1; else d[i][j] = 0; } } int ans = 0; for(int i = 1; i<= m; i++){ vector <int> _d; for(int j = 1; j <= n; j++) if(d[i][j]) _d.push_back(d[i][j]); sort(_d.begin(),_d.end()); int len = _d.size(); for(int j = 0; j < len; j++){ ans = max(ans, _d[j]*(len-j)); } } printf("%d\n",ans); } return 0;}
0 0
- hdu 2830 Matrix Swapping II
- HDU 2830 Matrix Swapping II
- hdu 2830 Matrix Swapping II
- hdu 2830 Matrix Swapping II
- hdu 2830 Matrix Swapping II
- hdu 2830 Matrix Swapping II
- HDU 2830 Matrix Swapping II
- hdu 2830 Matrix Swapping II
- hdu 2830 - Matrix Swapping II
- HDU 2830 Matrix Swapping II
- HDU 2830 Matrix Swapping II
- hdu 2830 Matrix Swapping II
- hdu 2830 Matrix Swapping II
- hdu 2830 Matrix Swapping II
- HDU 2830 Matrix Swapping II *
- HDU 2830 Matrix Swapping II
- #HDU 2830 Matrix Swapping II
- hdu 2830 Matrix Swapping II
- 关于signal, kill, mutex, spinlock的一些总结
- 优化MySQL性能的几种方法-总结
- 游戏礼包激活码案例分析
- js-静态、原型、实例属性
- 输入输出运算符重载( Overloading the I/O operators)
- HDU 2830 Matrix Swapping II
- ContentProvider和Uri详解
- Eclipse安装Maven插件
- 题目1000:计算a+b
- Android Service完全解析,关于服务你所需知道的一切
- nested exception is java.lang.OutOfMemoryError: PermGen space (java内存溢出,内存持久代不足的解决方式)
- 『IOS』
- android persistent属性研究
- 浏览器原理——渲染过程(一)