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. Google搜索解析

    Google搜索解析 是一款相似于Google趋势的SEO 在 线keyword工具,其官方提出的口号是“看看全世界的人们都在搜索些什么”.利用Google搜索解析,能够比較特定区域.类别.时间范围以 ...

  2. GDB踪函数的完整调用过程 及原理

    http://www.lenky.info/archives/2013/02/2202 Breakpoint , .so. (gdb) bt # .so. # .so. # .so. # .so. # ...

  3. mapreduce实战:统计美国各个气象站30年来的平均气温项目分析

    气象数据集 我们要写一个气象数据挖掘的程序.气象数据是通过分布在美国各地区的很多气象传感器每隔一小时进行收集,这些数据是半结构化数据且是按照记录方式存储的,因此非常适合使用 MapReduce 程序来 ...

  4. 再回首,Java温故知新(一):Java概述

    Java发展历程 Java的发展要追溯到1991年,Patrick Naughton(帕特里克·诺顿)和James Gosling(詹姆斯·高斯林)带领Sun公司的工程师打算为有线电视转换盒之类的消费 ...

  5. CoreText 实现图文混排

    CoreText 实现图文混排 相关博文推荐 IOS CoreText.framework - 基本用法 IOS CoreText.framework - 段落样子CTParagraphStyle h ...

  6. 2 - SQL Server 2008 之 使用SQL语句为现有表添加约束条件

    上一节讲的是直接在创建表的时候添加条件约束,但是有时候是在表格创建完毕之后,再添加条件约束的,那么这个又该如何实现? 其实,跟上一节所写的SQL代码,很多是相同的,只是使用了修改表的ALTER关键字及 ...

  7. Python 记录(一)

    一开始没发现3.5与2.x版本的区别,导致浪费了很多时间在导包等问题上: 如: Pyhton2中的urllib2工具包,在Python3中分拆成了urllib.request和urllib.error ...

  8. URAL 2032 - Conspiracy Theory and Rebranding【本源勾股数组】

    [题意] 给出三角形的三个边长,均是10^7以内的整数,问三角形的三个角的坐标是否能均是整数,输出其中任意一个解. [题解] 一开始想的是枚举一条边的横坐标,然后通过勾股定理以及算角度求出其他点的坐标 ...

  9. Android4.0的Alertdialog对话框,设置点击其他位置不消失

    Android4.0以上AlertDialog,包括其他自定义的dialog,在触摸对话框边缘外部,对话框消失. 可以设置这么一条属性,当然必须先AlertDialog.Builder.create( ...

  10. html获取gps坐标

    <script> function getLocation(){ var options={ enableHighAccuracy:true, maximumAge:1000 } if(n ...