Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
691 B
2
Indexable
Never
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main()
{
	int m,n;
	cin>>m>>n;
	int a[m+5][n+5];
	for (int i=1;i<=m;i++)
		for (int j=1;j<=n;j++) cin>>a[i][j];
	//-----------------------
	double ans=0;
	for (int i=2;i<=m-1;i++)
		for (int j=1;j<=n-2;j++)
			for (int x=j+2;x<=n;x+=2)
			if (a[i][j]==a[i][x])
			{
				int mid=(j+x)/2;
				int t=a[i][j];
				int cs=0;
				for (int y=1;y<=i-1;y++)
					if (a[y][mid]==t) 
					{
						cs=y;
						break;
					}
				if (cs!=0)
				for (int y=m;y>=i+1;y--)
					if (a[y][mid]==t) ans=max(ans,(y-cs)+2*sqrt(2*(i-cs)*(i-cs)));

			}
	cout<<fixed<<setprecision(2)<<ans;
	return 0;
}