1. When entering data, be careful
Two-dimensional promotion of 2.1506
Code:
#include <cstdio> #include <cstring> #include <algorithm>using namespace Std;const int inf=1<< 30;int a[1005][1005];int l[1005];int r[1005];int main () {int t; int m,n; int ans; Char s[10]; scanf ("%d", &t); memset (A,0,sizeof (a)); while (t--) {scanf ("%d%d", &m,&n); for (int i=1;i<=m;i++) {for (int j=1;j<=n;j++) {scanf ("%s", s); if (s[0]== ' F ') a[i][j]=1; else a[i][j]=0; }} Ans=-inf; for (int i=1;i<=m;i++) {for (int j=1;j<=n;j++) {if (a[i][j]==1) A[I][J]+=A[I-1][J]; } for (int j=1;j<=n;j++) {l[j]=j; while (L[j]>1&&a[i][l[j]-1]>=a[i][j]) l[j]=l[l[j]-1]; } for (int j=n;j>=1;j--) { R[j]=j; while (R[j]<n&&a[i][r[j]+1]>=a[i][j]) r[j]=r[r[j]+1]; } for (int j=1;j<=n;j++) {Ans=max (ans,a[i][j]* (r[j]-l[j]+1)); }} printf ("%d\n", 3*ans); } return 0;}
HDU 1505 City Game (two-dimensional promotion of hdu1506)