标签:efi namespace 后缀 reserve main tom uil tail mem
http://acm.hdu.edu.cn/showproblem.php?pid=1505
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
#include<cstdio> #include<cstring> #include<algorithm> #define N 1001 using namespace std; int a[N],b[N]; int q[N],tmp[N],head,tail; int l[N],r[N]; int ans; int n,m; char s[2]; void monotonous(int *c,int *d) { int h=1; while(h<=m && !c[h]) h++; if(h>m) return; q[0]=c[h]; tmp[0]=h; head=0; tail=1; for(int i=2;i<=m;i++) { if(!c[i]) while(head<tail) d[tmp[head++]]=i-1; else if(head==tail) q[tail]=c[i],tmp[tail++]=i; else { if(c[i]<q[tail-1]) while(head<tail && q[tail-1]>c[i]) d[tmp[--tail]]=i-1; q[tail]=c[i]; tmp[tail++]=i; } } while(head<tail) d[tmp[head++]]=tmp[tail-1]; } int main() { int T; char ch; scanf("%d",&T); for(int i=1;i<=T;i++) { ans=0; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { scanf("%s",s); if(s[0]==‘F‘) a[j]++,b[m-j+1]++; else a[j]=b[m-j+1]=0; } monotonous(a,r); monotonous(b,l); for(int i=1;i<=m;i++) tmp[i]=l[i]; for(int i=1;i<=m;i++) l[m-i+1]=m-tmp[i]+1; for(int i=1;i<=m;i++) ans=max(ans,(r[i]-l[i]+1)*a[i]); } printf("%d\n",ans*3); memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); } }
标签:efi namespace 后缀 reserve main tom uil tail mem
原文地址:http://www.cnblogs.com/TheRoadToTheGold/p/7300592.html