Cod sursa(job #659976)

Utilizator dutzulBodnariuc Dan Alexandru dutzul Data 11 ianuarie 2012 13:47:47
Problema DreptPal Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.77 kb
#include <fstream>
#define l 1010
using namespace std;
ifstream f("dreptpal.in");
ofstream g("dreptpal.out");
int i ,j,M[l][l],a[l][l],n,m,v[l],t,p,e,maxe;
int go()
{
  int st=j-1,dr=j+1;

  while (a[i][st]==a[i][dr]) st--,dr++;

  return (dr-j-1)*2+1;
}
int main()
{
  f>>n>>m;

  for(i=1; i<=n; i++) a[i][0]=-1;

  for(i=1; i<=n; i++) for(j=1; j<=m; j++) f>>a[i][j];


  for(i=1; i<=n; i++)
    for(j=1; j<=m; j++) M[i][j]=go();


  for(i=1; i<=m; i++)
    {
      for(j=1; j<=n; j++) v[j]=M[j][i];

      for(t=i,e=l; t<=n; t++,e=l)
        {
          for(p=1; p<=t; p++)
            {
              e=min(e,v[p]);

              maxe=max(maxe,e*p);
            }
        }
    }
g<<maxe<<'\n';

  f.close();
  g.close();
  return 0;
}