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个 ...
随机推荐
- 向页面动态添加外部js
var script = document.createElement("script"); script.src = '/static/js/view/'+url+'.js'; ...
- Delphi版IP地址与整型互转
Delphi版IP地址与整型互转 unit Unit11; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphic ...
- (转)windows上virtualenv 安装及使用
[注意]要在某个含有空格的目录下面创建virtualenv环境,就要安装 win32api . 原文地址:http://blog.csdn.net/liuchunming033/article/det ...
- Quartz总结(三):动态修改定时器一
package com.mc.bsframe.job; import org.quartz.Scheduler; import org.quartz.SchedulerException; impor ...
- MVC和三层架构的区别
MVC是一种设计模式,Modal,View,Controller,三层分开,解开耦合,方便替换. 三层架构包括 UI层,业务逻辑层,Dao层.UI层负责展示数据,业务逻辑层具体处理数据,Dao层负责和 ...
- 在java中和javascript中过滤掉类似于img形式的字符串,从而不显示图片
1:javascript过滤掉<img></img>和<img />形式的字符串 <!DOCTYPE html PUBLIC "-//W3C//DT ...
- PAT (Advanced Level) 1079. Total Sales of Supply Chain (25)
树的遍历. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...
- JS——实现短信验证码的倒计时功能(没有验证码,只有倒计时)
1.功能描述 当用户想要获取验证码时,就点击 免费获取验证码 ,然后开始倒计时,倒计时期间按钮文字为剩余时间x秒,且不可按状态,倒计时结束后,按钮更改为点击重新发送. 2.分析 必须用到定时器.按钮点 ...
- 制作win10 usb 启动盘
Rufus 是一个开源的USB启动盘制作程序.其特点就是快速,且支持各种系统,包括各种windows系统,linux系统,使用也很简单. Rufus主页: http://rufus.akeo.ie/ ...
- nginx 防 webshell 跨目录
对于在一台服务器上有多个虚拟主机的人来说,Apache有一个很好用的地方---配置php_admin_value,在里面配置一下 open_basedir就可以了. 但是Nginx却没有这样的设置 ...