LA 3029 City Game

题目:City Game


思路:扫描线


代码:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <cstring>
#include <map>
#include <cmath>
using namespace std;

#define maxn 1000

int n,m;

bool a[maxn+5][maxn+5];
int up[maxn+5][maxn+5]={0},Left[maxn+5][maxn+5]={0},Right[maxn+5][maxn+5]={0};

int main() {

	int T;
	scanf("%d",&T);
	
	while(T--){
		scanf("%d%d",&m,&n);
		for(int i=1;i<=m;i++){
			for(int j=1;j<=n;j++){
				char x;
				while(scanf("%c",&x)&&x!='R'&&x!='F');
				if(x=='R') a[i][j]=1;
				else a[i][j]=0;
			}
		}
		
		int ans=0;
		
		for(int i=1;i<=m;i++){
			int l=0,r=n+1;
			for(int j=1;j<=n;j++){
				if(a[i][j]) {
					l=j;
					Left[i][j]=1;
					up[i][j]=0;
				} else {
					up[i][j]=up[i-1][j]+1;
					if(i==1) Left[i][j]=l+1;
					else Left[i][j]=max(Left[i-1][j],l+1);
				}
			}
			for(int j=n;j>=1;j--){
				if(a[i][j]){
					r=j;
					Right[i][j]=n;
				} else {
					if(i==1) Right[i][j]=r-1;
					else Right[i][j]=min(Right[i-1][j],r-1);
					ans=max(ans,up[i][j]*(Right[i][j]-Left[i][j]+1));
				}
			}
		}
		printf("%d\n",ans*3);
	}

	return 0;
}


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值