City Game
hdu1505:http://acm.hdu.edu.cn/showproblem.php?pid=1505
题解:给你一个字符矩阵,里面有R和F两种字符,然后让你找一个最大的子矩阵,这个最大的子矩阵只含有F。
题解:在队友的提示下和上一题的影响,我先处理出每一行,以该行为起点的连续F的高度,然后每一行的情况问题就转化成上一题的问题,然后枚举每一行就可以了。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=;
int n,m;
char mp[N][N];
int dp[N][N];
int ll[N],rr[N],ans;
int main(){
int cas;
scanf("%d",&cas);
while(cas--){
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
cin>>mp[i][j];
for(int i=;i<=m;i++){
int temp=;
for(int j=;j<=n;j++){
if(mp[j][i]=='F')
++temp;
else
temp=;
dp[j][i]=temp;
}
}
ans=;
for(int i=n;i>=;i--){
memset(ll,,sizeof(ll));
memset(rr,,sizeof(rr));
dp[i][]=-;dp[i][m+]=-;
for(int j=;j<=m;j++){
ll[j]=j;
if(j==)continue;
int t=j-;
while(dp[i][j]<=dp[i][t]){
ll[j]=ll[t];
t=ll[t]-;
}
}
for(int j=m;j>=;j--){
rr[j]=j;
if(j==m)continue;
int t=j+;
while(dp[i][j]<=dp[i][t]){
rr[j]=rr[t];
t=rr[t]+;
}
}
for(int k=;k<=m;k++){
ans=max(ans,(rr[k]-ll[k]+)*dp[i][k]);
}
}
printf("%d\n",ans*);
} }
City Game的更多相关文章
- BZOJ 2001: [Hnoi2010]City 城市建设
2001: [Hnoi2010]City 城市建设 Time Limit: 20 Sec Memory Limit: 162 MBSubmit: 1132 Solved: 555[Submit][ ...
- History lives on in this distinguished Polish city II 2017/1/5
原文 Some fresh air After your time underground,you can return to ground level or maybe even a little ...
- History lives on in this distinguished Polish city 2017/1/4
原文 History lives on in this distinguished Polish city Though it may be ancient. KraKow, Poland, is a ...
- #1094 : Lost in the City
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi gets lost in the city. He does not know where he is ...
- GeoIP Legacy City数据库安装说明
Here is a brief outline of the steps needed to install GeoIP Legacy City on Linux/Unix. The installa ...
- [POJ3277]City Horizon
[POJ3277]City Horizon 试题描述 Farmer John has taken his cows on a trip to the city! As the sun sets, th ...
- 2015年第8本(英文第7本):the city of ember 微光城市
书名:the City of Ember(中文名:微光城市) 作者:Jeanne DuPrau 单词数:6.2万 不重复单词数:未知 首万词不重复单词数:未知 蓝思值:未知 阅读时间:2015年4月2 ...
- 离散化+线段树 POJ 3277 City Horizon
POJ 3277 City Horizon Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 18466 Accepted: 507 ...
- HDU 1505 City Game (hdu1506 dp二维加强版)
F - City Game Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submi ...
- URAL 1139 City Blocks(数论)
The blocks in the city of Fishburg are of square form. N avenues running south to north and Mstreets ...
随机推荐
- 在RichTextBox控件中插入图片
. 在RichTextBox控件中插入图片 关键点 . 实现过程 . public void ShowInsertImageDlg() { OpenFileDialog OpenFileD ...
- docker 下 安装rancher 笔记
sudo yum update 更新系统环境 curl -sSL https://get.docker.com/ | sh 安装最新docker版本 systemctl start docker.se ...
- 怎样让HTML5调用手机摄像头拍照——实践就是一切
原文:怎样让HTML5调用手机摄像头拍照--实践就是一切 NanShan 小编将思路提供给了大家.学编程最重要的是实践,我这尽管有完好的代码,可是希望大家都能够自己写出属于自己的代码 HTML5 Th ...
- vim note(6)--vim的一个较全的介绍(转)
vim的配置文件 ~/.vimrc 用户的默认配置文件 ~/.vim/plugin/ 用户的默认脚本文件的存放文件夹 ~/.vim/ftplugin/ 用户的默认文件类型相关脚本文件的 ...
- winserve2008下不能运行winXP下开发的应用程序→更改“兼容性”
winserve2008下不能运行winXP下开发的应用程序 对策:更该“兼容性”
- objective-c 中的关联介绍
objective-c 中的关联介绍 转载请注明CSDN博客上的出处: http://blog.csdn.net/daiyibo123/article/details/46471993 如何设置关联 ...
- thread跟Runnable实现多线程
//两种实现方式的区别和联系: //在程序开发中只要是多线程肯定永远以实现Runnable接口为主,因为实现Runnable接口相比继承Thread类有如下好处: //避免点继承的局限,一个类可以继承 ...
- jsp页面表单的遍历要怎么写
1.传统的方式使用request.getAttribute(“list”);获取表单的值, 2.也可以用struts2提供的标签进行遍历 备注 // 传统的接受参数方法 // String sfz=t ...
- List指定字段赋特定值(非循环) asp.net
List<Cart> cartd=cartd.Where(p => (p.Id= "123").Length > -1).ToList(); 把Id的值都赋 ...
- 用WebStorm调试本地html(含嵌入的javascript).
题外话: 以前很少能调试,甚至以为不能调试(好笨),后来我看了一本叫做<<Learning Three.js>>的一本书后,里面推荐有几种javascript的编辑工具,都蛮好 ...