#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<sstream>
#include<string>
#include<climits>
#include<stack>
#include<set>
#include<bitset>
#include<cmath>
#include<deque>
#include<map>
#include<queue>
#define iinf 0x7f7f7f7f
#define linf 1000000000000000000LL
#define dinf 1e200
#define eps 1e-11
#define all(v) (v).begin(),(v).end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define lng long long
#define sqr(a) ((a)*(a))
#define pii pair<int,int>
#define pll pair<lng,lng>
#define pss pair<string,string>
#define pdd pair<double,double>
#define X first
#define Y second
#define pi 3.14159265359
#define ff(i,xi,n) for(int i=xi;i<=(int)(n);++i)
#define ffd(i,xi,n) for(int i=xi;i>=(int)(n);--i)
#define ffl(i,r) for(int i=head[r];i!=-1;i=edge[i].next)
#define ffe(i,r) for(_edge *i=head[r];i;i=i->next)
#define cc(i,j) memset(i,j,sizeof(i))
#define two(x) ((lng)1<<(x))
#define lson l , mid , rt << 1
#define rson mid + 1 , r , rt << 1 | 1
#define mod 1000000007
#define pmod(x,y) (x%y+y)%y
using namespace std;
typedef vector<int> vi;
typedef vector<string> vs;
template<class T> inline void checkmax(T &x,T y)
{
if(x<y) x=y;
}
template<class T> inline void checkmin(T &x,T y)
{
if(x>y) x=y;
}
template<class T> inline T Min(T x,T y)
{
return (x>y?y:x);
}
template<class T> inline T Max(T x,T y)
{
return (x<y?y:x);
}
template<class T> T Abs(T a)
{
return a>0?a:(-a);
}
template<class T> inline T lowbit(T n)
{
return (n^(n-1))&n;
}
template<class T> inline int countbit(T n)
{
return (n==0)?0:(1+countbit(n&(n-1)));
}
lng Pow(lng x,lng y)
{
if(!y) return 1;
lng res=Pow(x*x%mod,y/2);
if(y&1) res=res*x%mod;
return res;
}
char a[1111][1111];
int h[1111];
int l[1111];
int r[1111];
int q[1111],fr,re;
int n,m;
char w;
char d[4]={"abc"};
inline bool g(char &c)
{
if(w=='a') return c=='a'||c=='w'||c=='y'||c=='z';
if(w=='b') return c=='b'||c=='w'||c=='x'||c=='z';
if(w=='c') return c=='c'||c=='y'||c=='x'||c=='z';
return 1;
}
inline int f()
{
int res=0;
cc(h,0);
ff(i,1,n)
{
int ma=0;
ff(j,1,m)
{if(g(a[i][j])) h[j]=h[j]+1;
else h[j]=0;
l[j]=1,r[j]=m;
checkmax(ma,h[j]);
}
if(ma*m<=res) continue;
fr=1,re=0;
ff(j,1,m)
{
while(fr<=re&&h[q[re]]>h[j]) r[q[re]]=j-1,--re;
q[++re]=j;
}
fr=1,re=0;
ffd(j,m,1)
{
while(fr<=re&&h[q[re]]>h[j]) l[q[re]]=j+1,--re;
q[++re]=j;
}
ff(j,1,m)
checkmax(res,h[j]*(r[j]-l[j]+1));
}
return res;
}
int main()
{
while(scanf("%d%d",&n,&m)==2)
{
ff(i,1,n)
{
getchar();
ff(j,1,m)
a[i][j]=getchar();
}
int ans=-iinf;
ff(opt,0,2)
{
w=d[opt];
checkmax(ans,f());
}
printf("%d\n",ans);
}
return 0;
}
hdu 2870 Largest Submatrix
最新推荐文章于 2016-11-20 16:33:57 发布