Pagini recente » Cod sursa (job #2268457) | Cod sursa (job #163229) | Cod sursa (job #425305) | Cod sursa (job #2558008) | Cod sursa (job #840503)
Cod sursa(job #840503)
#include <iostream>
#include <fstream>
#include <algorithm>
#define DN 1004
using namespace std;
int dp[DN][DN],a[DN][DN];
int main()
{
int n,m,amax=0;
ifstream f("dreptpal.in");
ofstream g("dreptpal.out");
f>>n>>m;
for(int i=1;i<=n;++i)
for(int j=1;j<=m;++j)
f>>a[i][j];
for(int i=1;i<=n;++i)
for(int j=1;j<=m;++j)
{
int dr=j+1,lf=j-1;
while(dr<=m && lf>=1 && a[i][dr]==a[i][lf])
++dp[i][j],--lf,++dr;
dp[i][j]=dp[i][j]*2+1;
int H=0,L=dp[i][j];
for(int p=i;p>=1;--p)
{
++H;
L=min(L,dp[p][j]);
amax=max(amax,H*L);
}
}
g<<amax;
return 0;
}