hdu 1505

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1505

思路:完全就是hdu 1506的加强版,只要取定第i行,这样就可以用1506的方法来做了,最后加个for循环就行了;

View Code
 1 #include<iostream>
 2 #include<algorithm>
 3 const int N=1100;
 4 using namespace std;
 5 int l[N][N],r[N][N],h[N][N];
 6 char map[N][N];
 7 
 8 int main(){
 9     int _case;
10     scanf("%d",&_case);
11     while(_case--){
12         int n,m;
13         scanf("%d%d",&n,&m);
14         for(int i=1;i<=m;i++){
15             h[0][i]=0;
16         }
17         for(int i=1;i<=n;i++){
18             for(int j=1;j<=m;j++){
19                 scanf("%s",&map[i][j]);
20                 l[i][j]=j,r[i][j]=j;
21                 if(map[i][j]=='F'){
22                     h[i][j]=h[i-1][j]+1;
23                 }else if(map[i][j]=='R'){
24                     h[i][j]=0;
25                 }
26             }
27         }
28         int ans=0,Max=0;
29         for(int i=1;i<=n;i++){
30             h[i][0]=h[i][m+1]=-1;
31             for(int j=1;j<=m;j++){
32                 while(h[i][l[i][j]-1]>=h[i][j])
33                     l[i][j]=l[i][l[i][j]-1];
34             }
35             for(int j=m;j>=1;j--){
36                 while(h[i][r[i][j]+1]>=h[i][j])
37                     r[i][j]=r[i][r[i][j]+1];
38             }
39             for(int j=1;j<=m;j++){
40                 ans=(r[i][j]-l[i][j]+1)*h[i][j];
41                 Max=max(ans,Max);
42             }
43         }
44         printf("%d\n",3*Max);
45     }
46     return 0;
47 }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值