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个 ...
随机推荐
- 篇一:eclipse创建maven工程
一.概览 maven创建的项目主要分为三类:war(网页工程).jar(Java工程).pom(父工程); war:网页工程,包含webapp,用于view层 jar:Java工程,用于提供方法.se ...
- Unity中www的基本应用
Unity的www主要支持HTTP中的GET和POST方式,GET方式会将请求附加到URL后,POST方式则是通过FORM的形式提交. 以下为Unity客户端的信息: using UnityEngin ...
- angularJs中ngModel的坑
angular中指令被用的最多的除了ng-repeat之外就非他莫属了吧,由于各种业务的需求,我们经常需要去写一些继承ngModel的指令,来满足各种奇葩需求,最多的莫过于表单的验证啦,另外你在封装一 ...
- Win7+QTP10.0+IE9无法启动IE的解决方法
请安装QTP补丁QTP_00626. 更多补丁请查阅:http://www.cnblogs.com/testware/archive/2010/10/13/1849985.html
- PAT (Advanced Level) 1059. Prime Factors (25)
素因子分解. #include<iostream> #include<cstring> #include<cmath> #include<algorithm& ...
- [iOS]C语言技术视频-14-指针变量高级用法(函数指针)
下载地址: 链接: http://pan.baidu.com/s/1ykyg2 密码: fg5t
- Android学习笔记之Intent(1)
1.Intent指定启动目标组件 2.Intentfilter描述基本组件所在地址 3.其他包引入资源文件时记得引入R所在的包 package com.jikexueyuan.intent; impo ...
- [zoj解题] 1203
#include <stdio.h> #include <stdlib.h> #include <math.h> #define MAXN 100 #define ...
- LB 高可扩展性集群(负载均衡集群)
一.什么是负载均衡 首先我们先介绍一下什么是负载均衡: 负载平衡(Load balancing)是一种计算机网络技术,用来在多个计算机(计算机集群).网络连接.CPU.磁盘驱动器或其他资源中分配负载, ...
- Nginx 虚拟主机下支持Pathinfo并隐藏入口文件的完整配置
server { listen 80; server_name zuqiu.com; # 设置你的域名 index index.html index.htm index.php; root D:/wn ...