hdu2830 Matrix Swapping II(DP)
来源:互联网 发布:太平洋炒股软件下载 编辑:程序博客网 时间:2024/04/30 03:34
题意:给你一个矩阵,里面的数字只有0和1两种,其中,列可以任意移动。问如何移动可以使某个子矩阵中元素全部是1,求出这个最大子矩阵的面积。
思路:由于列可以任意移动,那么显然把高度大的都放到一堆里面是最优的,那么排个序就可以像HDU1506那样做了
#include<bits\stdc++.h>using namespace std;const int maxn = 2005;char mp[maxn][maxn];int h[maxn];int hh[maxn];bool cmp(int a,int b){return a>b;}int main(){ int n,m; while(scanf("%d%d",&n,&m)!=EOF) { int ans = 0;// getchar(); for(int i = 1;i<=n;i++) {// memset(h,0,sizeof(h)); for(int j = 1;j<=m;j++) { scanf(" %c",&mp[i][j]); if(mp[i][j]=='1') h[j]++; else h[j]=0; hh[j]=h[j]; } sort(hh+1,hh+1+m,cmp); for (int j = 1;j<=m;j++) ans = max(ans,hh[j]*j);// getchar(); } printf("%d\n",ans); }}
0 0
- hdu2830 Matrix Swapping II(DP)
- hdu2830 Matrix Swapping II--DP
- hdu2830 Matrix Swapping II 【dp】
- HDU2830--Matrix Swapping II
- HDU2830-Matrix Swapping II
- Matrix Swapping II hdu2830
- HDu 2830 Matrix Swapping II(dp)
- HDU-2830-Matrix Swapping II(DP)
- Matrix Swapping II(DP,最大矩形问题)
- hdu 2830 Matrix Swapping II (dp+树状数组)
- Matrix Swapping II - HDU 2830 dp
- hdu - 2830 - Matrix Swapping II(排序)
- Matrix Swapping II
- Matrix Swapping II
- Matrix Swapping II
- Matrix Swapping II
- 2830 Matrix Swapping II
- HDU 2830 Matrix Swapping II (DP,最大全1矩阵)
- HTML5培训第14节课堂笔记(列表滑动删除的实现、侧滑菜单的生成)
- HDU 1014 Uniform Generator【公约数】
- 街拍白连衣裙美女
- 一个操作系统的实现(1)-准备工作
- C# 按钮添加事件
- hdu2830 Matrix Swapping II(DP)
- 数据库utf-8
- 战略游戏_ssl1230_树形dp
- Qt中的MDI多对话框程序框架
- 每个程序员都应该了解的内存知识
- 杭电试题简单分类
- MVP+Retrofit+RXAndroid使用详解
- 广场街拍白裙美女
- UVa 12506 Shortest Names