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的更多相关文章

  1. BZOJ 2001: [Hnoi2010]City 城市建设

    2001: [Hnoi2010]City 城市建设 Time Limit: 20 Sec  Memory Limit: 162 MBSubmit: 1132  Solved: 555[Submit][ ...

  2. 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 ...

  3. 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 ...

  4. #1094 : Lost in the City

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi gets lost in the city. He does not know where he is ...

  5. GeoIP Legacy City数据库安装说明

    Here is a brief outline of the steps needed to install GeoIP Legacy City on Linux/Unix. The installa ...

  6. [POJ3277]City Horizon

    [POJ3277]City Horizon 试题描述 Farmer John has taken his cows on a trip to the city! As the sun sets, th ...

  7. 2015年第8本(英文第7本):the city of ember 微光城市

    书名:the City of Ember(中文名:微光城市) 作者:Jeanne DuPrau 单词数:6.2万 不重复单词数:未知 首万词不重复单词数:未知 蓝思值:未知 阅读时间:2015年4月2 ...

  8. 离散化+线段树 POJ 3277 City Horizon

    POJ 3277 City Horizon Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 18466 Accepted: 507 ...

  9. HDU 1505 City Game (hdu1506 dp二维加强版)

    F - City Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submi ...

  10. URAL 1139 City Blocks(数论)

    The blocks in the city of Fishburg are of square form. N avenues running south to north and Mstreets ...

随机推荐

  1. Windows 下OpenSSL 安装

    安装环境: .操作系统:Windows XP SP2 2.C++编译器:VC++ 6.0 下载: 下载ActivePerl  5.10.1.1007(最新的版本或较低的版本也可以): 下载地址:htt ...

  2. Present ViewController Modally

    一.主要用途 弹出模态ViewController是IOS变成中很有用的一个技术,UIKit提供的一些专门用于模态显示的ViewController,如UIImagePickerController等 ...

  3. [Javascript] Creating an Immutable Object Graph with Immutable.js Map()

    Learn how to create an Immutable.Map() through plain Javascript object construction and also via arr ...

  4. Linux下使用w命令和uptime命令查看系统负载

    在Linux系统中查询系统CPU和内存的负载(使用率)时,我们通常习惯于使用top.atop或者ps,这篇文章将要给大家介绍如何使用w命令和uptime命令来查看系统的负载情况,对于uptime命令, ...

  5. JAVA大集合数据分批次进行切割处理

    今天遇到一个大集合里面的数据删除问题, 因为是一个大集合,如果同时传递到数据库,那么就会造成数据库压力 所以分批次的进行批量操作 其实 也可以采用多线程来处理或者多批次加多线程来处理都是可以的 下面的 ...

  6. jersey + tomcat 实现restful风格

    本文参考 http://www.cnblogs.com/bluesfeng/archive/2010/10/28/1863816.html 环境: idea 15.0.2 jersey 1.3 tom ...

  7. 在Mac OS X下安装Android Studio

    在Mac OS X下安装Android Studio只需要几步. 1. 下载Android Studio安装包(.dmg). 2. 打开Terminal输入java -version命令查看是否已安装 ...

  8. PHP 的try catch 报错捕获机制

    首先上代码: try { echo 'Never executed'; echo "<br>"; if(1<0){ echo 'end'; }else{ thro ...

  9. 关于Android4.x系统默认显示方向各种修改

    1.设置属性值 在device.mk文件中加入PRODUCT_PROPERTY_OVERRIDES += \ ro.sf.hwrotation=180 2.设置屏幕默认显示方向 在frameworks ...

  10. ASP 调用dll(VB)及封装dll实例

    ASP调用dll及封装dll实例,封装为dll可以提供运行效率,加密代码. 打开VB6,新建ActiveX DLL 2.在工程引用中加入Microsoft Active Server Pages Ob ...