Cod sursa(job #638040)

Utilizator ProcopliucProcopliuc Adrian Procopliuc Data 20 noiembrie 2011 18:19:21
Problema DreptPal Scor 50
Compilator cpp Status done
Runda .com 2011 Marime 0.65 kb
# include <fstream>
using namespace std;
ifstream f ("dreptpal.in");
ofstream g ("dreptpal.out");
int a[1005][1005],i,j,n,m,maxim,x;

int calc (int i,int j)
{
	int i1=1,j1=1,mm=0,nmax=10000;
	while (a[i][j+j1]==a[i][j-j1] && j-j1>=1 && j+j1<=m)
	{
		i1=1;
		while (a[i+i1][j+j1]==a[i+i1][j-j1] && i1<=nmax && i1+i<=n)
			i1++;
		nmax=i1-1;
		if (mm<(2*j1+1)*(nmax+1))
			mm=(2*j1+1)*(nmax+1);
	j1++;
	}
	return mm;
}


int main ()
{
	f>>n>>m;
	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++)
		{
			x=calc (i,j);
			if (maxim<x)
				maxim=x;
		}
		
	g<<maxim;
	return 0;
	
}