Language: C++

#include<bits/stdc++.h>
#define N 500
//#define int long long
#define INF 1e9
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
inline int read()
{
	register char cc = getchar();register int cn(0), flus(1);
	while(cc > '9' || cc < '0') {if(cc == '-') flus = -flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
	return cn * flus; 
}
int e[N][N];
int tmp[N][N];
int a, b;
inline void floyd()
{
	rep(k,1,a * b)
	{
		rep(i,1,a * b)
		{
			rep(j,1,a * b)
			{
				e[i][j]=min(e[i][j],e[i][k]+e[k][j]);
			}
		}
	}
}
signed main()
{
	a = read();
	b = read();
	rep(i, 1, a * b) 
	{
		rep(j, 1, a * b) 
		{
			if(i != j) e[i][j] = 1e9;
		}
	}
	rep(i, 1, a)
	{
		char s[N];
		scanf("%s",s + 1);
		rep(j, 1, b)
		{
			if(s[j] == '.') tmp[i][j] = 1;
		}
	}
	rep(i, 1, a)
	{
		rep(j, 1, b)
		{
			int k = i - 1;
			if(tmp[i][j])
			{
				//printf("i = %d j = %d\n",i,j);
				//printf("tmp[i][j - 1] = %d\n",tmp[i][j - 1]);
				if(tmp[i][j - 1])
				{
					e[k  b + j - 1][k  b + j] = 1;
					e[k  b + j][k  b + j - 1] = 1;
					//printf("added(%d,%d)\n",i  b + j - 1,i  b + j);
				}
				if(tmp[i][j + 1])
				{
					e[k  b + j + 1][k  b + j] = 1;
					e[k  b + j][k  b + j + 1] = 1;
				}  
				if(tmp[i + 1][j]) 
				{
					e[(k + 1)  b + j][k  b + j] = 1;
					e[k  b + j][(k + 1)  b + j] = 1;
				}
				if(tmp[i - 1][j])
				{
					e[(k - 1)  b + j][k  b + j] = 1;
					e[k  b + j][(k - 1)  b + j] = 1;
				}
			}
		}
	}
	floyd();
	int _max = 0;
	/*rep(i, 1, a * b)
	{
		rep(j, 1, b * a)
		{
			printf("%d ",e[i][j]);
		}
		puts("");
	}*/
	rep(i, 1, a * b)
	{
		rep(j, 1, b * a)
		{
			if(e[i][j] > max && e[i][j] < 1e9) max = e[i][j];
		}
	}
	printf("%d\n",_max);
	return 0;	
}

Compiler output:
a.cc: In function 'int read()':
a.cc:9:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    9 |         register char cc = getchar();register int cn(0), flus(1);
      |                       ^~
a.cc:9:51: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    9 |         register char cc = getchar();register int cn(0), flus(1);
      |                                                   ^~
a.cc:9:58: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    9 |         register char cc = getchar();register int cn(0), flus(1);
      |                                                          ^~~~
a.cc: In function 'void floyd()':
a.cc:19:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   19 |         rep(k,1,a * b)
      |             ^
a.cc:5:39: note: in definition of macro 'rep'
    5 | #define rep(i, l, r) for(register int i = l; i <= r; ++ i)
      |                                       ^
a.cc:21:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   21 |                 rep(i,1,a * b)
      |                     ^
a.cc:5:39: note: in definition of macro 'rep'
    5 | #define rep(i, l, r) for(register int i = l; i <= r; ++ i)
      |                                       ^
a.cc:23:29: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   23 |                         rep(j,1,a * b)
      |                             ^
a.cc:5:39: note: in definition of macro 'rep'
    5 | #define rep(i, l, r) for(register int i = l; i <= r; ++ i)
      |                                       ^
a.cc: In function 'int main()':
a.cc:34:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   34 |         rep(i, 1, a * b)
      |             ^
a.cc:5:39: note: in definition of macro 'rep'
    5 | #define rep(i, l, r) for(register int i = l; i <= r; ++ i)
      |                                       ^
a.cc:36:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   36 |                 rep(j, 1, a * b)
      |                     ^
a.cc:5:39: note: in definition of macro 'rep'
    5 | #define rep(i, l, r) for(register int i = l; i <= r; ++ i)
      |                                       ^
a.cc:41:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   41 |         rep(i, 1, a)
      |             ^
a.cc:5:39: note: in definition of macro 'rep'
    5 | #define rep(i, l, r) for(register int i = l; i <= r; ++ i)
      |                                       ^
a.cc:45:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   45 |                 rep(j, 1, b)
      |                     ^
a.cc:5:39: note: in definition of macro 'rep'
    5 | #define rep(i, l, r) for(register int i = l; i <= r; ++ i)
      |                                       ^
a.cc:50:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   50 |         rep(i, 1, a)
      |             ^
a.cc:5:39: note: in definition of macro 'rep'
    5 | #define rep(i, l, r) for(register int i = l; i <= r; ++ i)
      |                                       ^
a.cc:52:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   52 |                 rep(j, 1, b)
      |                     ^
a.cc:5:39: note: in definition of macro 'rep'
    5 | #define rep(i, l, r) for(register int i = l; i <= r; ++ i)
      |                                       ^
a.cc:61:44: error: expected ']' before 'b'
   61 |                                         e[k  b + j - 1][k  b + j] = 1;
      |                                            ^ ~
      |                                            ]
a.cc:61:44: error: expected ';' before 'b'
   61 |                                         e[k  b + j - 1][k  b + j] = 1;
      |                                            ^ ~
      |                                            ;
a.cc:62:44: error: expected ']' before 'b'
   62 |                                         e[k  b + j][k  b + j - 1] = 1;
      |                                            ^ ~
      |                                            ]
a.cc:62:44: error: expected ';' before 'b'
   62 |                                         e[k  b + j][k  b + j - 1] = 1;
      |                                            ^ ~
      |                                            ;
a.cc:67:44: error: expected ']' before 'b'
   67 |                                         e[k  b + j + 1][k  b + j] = 1;
      |                                            ^ ~
      |                                            ]
a.cc:67:44: error: expected ';' before 'b'
   67 |                                         e[k  b + j + 1][k  b + j] = 1;
      |                                            ^ ~
      |                                            ;
a.cc:68:44: error: expected ']' before 'b'
   68 |                                         e[k  b + j][k  b + j + 1] = 1;
      |                                            ^ ~
      |                                            ]
a.cc:68:44: error: expected ';' before 'b'
   68 |                                         e[k  b + j][k  b + j + 1] = 1;
      |                                            ^ ~
      |                                            ;
a.cc:72:50: error: expected ']' before 'b'
   72 |                                         e[(k + 1)  b + j][k  b + j] = 1;
      |                                                  ^ ~
      |                                                  ]
a.cc:72:50: error: expected ';' before 'b'
   72 |                                         e[(k + 1)  b + j][k  b + j] = 1;
      |                                                  ^ ~
      |                                                  ;
a.cc:73:44: error: expected ']' before 'b'
   73 |                                         e[k  b + j][(k + 1)  b + j] = 1;
      |                                            ^ ~
      |                                            ]
a.cc:73:44: error: expected ';' before 'b'
   73 |                                         e[k  b + j][(k + 1)  b + j] = 1;
      |                                            ^ ~
      |                                            ;
a.cc:77:50: error: expected ']' before 'b'
   77 |                                         e[(k - 1)  b + j][k  b + j] = 1;
      |                                                  ^ ~
      |                                                  ]
a.cc:77:50: error: expected ';' before 'b'
   77 |                                         e[(k - 1)  b + j][k  b + j] = 1;
      |                                                  ^ ~
      |                                                  ;
a.cc:78:44: error: expected ']' before 'b'
   78 |                                         e[k  b + j][(k - 1)  b + j] = 1;
      |                                            ^ ~
      |                                            ]
a.cc:78:44: error: expected ';' before 'b'
   78 |                                         e[k  b + j][(k - 1)  b + j] = 1;
      |                                            ^ ~
      |                                            ;
a.cc:93:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   93 |         rep(i, 1, a * b)
      |             ^
a.cc:5:39: note: in definition of macro 'rep'
    5 | #define rep(i, l, r) for(register int i = l; i <= r; ++ i)
      |                                       ^
a.cc:95:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   95 |                 rep(j, 1, b * a)
      |                     ^
a.cc:5:39: note: in definition of macro 'rep'
    5 | #define rep(i, l, r) for(register int i = l; i <= r; ++ i)
      |                                       ^
a.cc:97:36: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator>'
   97 |                         if(e[i][j] > max && e[i][j] < 1e9) max = e[i][j];
      |                            ~~~~~~~~^~~~~
a.cc:97:72: error: overloaded function with no contextual type information
   97 |                         if(e[i][j] > max && e[i][j] < 1e9) max = e[i][j];
      |                                                                        ^