您的位置:首页 > 编程语言 > C语言/C++

【UVALive】3029.City Game<C++>

2015-11-23 21:57 471 查看
[code]#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
char input[1001][1001],judge;
int up[1001][1001],Left[1001][1001],Right[1001][1001];
int main(){
    int m,n,lnear,rnear,answer,times;
    scanf("%d",×);
    for(int k=1;k<=times;k++){
        answer=0;
        scanf("%d%d",&m,&n);
        memset(up,0,sizeof(up));
        memset(Left,0,sizeof(Left));
        memset(Right,0x7f,sizeof(Right));
        for(int i=1;i<=m;i++)
            for(int j=1;j<=n;j++){
                scanf("%c",&judge);
                if(judge==' '||judge=='\n')
                    if(j==1){
                        j=n;
                        i--;
                    }
                    else
                        j--;
                else
                    input[i][j]=judge;
            }
        for(int i=1;i<=m;i++){
            lnear=0;
            for(int j=1;j<=n;j++)
                if(input[i][j]!='R'){
                    up[i][j]=up[i-1][j]+1;
                    Left[i][j]=max(Left[i-1][j],lnear+1);
                }
                else
                    lnear=j;
            rnear=n+1;
            for(int j=n;j>=1;j--){
                if(input[i][j]!='R')
                    Right[i][j]=min(Right[i-1][j],rnear-1);
                else
                    rnear=j;
                answer=max(answer,up[i][j]*(Right[i][j]-Left[i][j]+1));
            }
        }
        printf("%d\n",answer*3);
    }
    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: