标签:style blog http io ar color os sp for
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1505
#include <cstdio> #include <cstring> #include <cmath> #include <iostream> #include <algorithm> #include <queue> #include <cstdlib> #include <vector> #include <set> #include <map> #define LL long long #define inf 1<<30 using namespace std; char s[1010][1010]; int a[1005][1005],l[1010],r[1010]; int main() { int T,t,n,m; cin>>T; while(T--) { cin>>n>>m; memset(a,0,sizeof(a)); for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) { cin>>s[i][j]; } for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) { if(s[i][j]==‘F‘)a[i][j]=a[i-1][j]+1; else a[i][j]=0; } int ans=-1; for(int i=1;i<=n;i++) { l[1]=1;r[m]=m; for(int j=2;j<=m;j++) { t=j; while(t>1&&a[i][j]<=a[i][t-1])t=l[t-1]; l[j]=t; } for(int j=m-1;j>=1;j--) { t=j; while(t<m&&a[i][j]<=a[i][t+1])t=r[t+1]; r[j]=t; } for(int j=1;j<=m;j++) ans=max(ans,(r[j]-l[j]+1)*a[i][j]); } printf("%d\n",ans*3); } }
标签:style blog http io ar color os sp for
原文地址:http://www.cnblogs.com/lienus/p/4119962.html