Language: C++

#include<bits/stdc++.h>
using namespace std;

#define REP(i,j) for(int i=1;i<=j;i++)

char maze[21][21];
int max_step,step[21][21];
bool visit[21][21];
int dx[5]= {0,1,-1,0,0};
int dy[5]= {0,0,0,1,-1};

struct node {
	int x,y;
} note;
queue<node> q;

int main() {
	int x,y;
	scanf("%d%d",&x,&y);
	REP(i,x) {
		REP(j,y) {
			cin>>maze[i][j];
		}
	}
	REP(i,x) {
		REP(j,y) {
			memset(step,0,sizeof(step));
			memset(visit,0,sizeof(visit));
			if(maze[i][j]=='#')
			continue;
			q.push(node {i,j});
			while(!q.empty()) {
				node u=q.front();
				q.pop();
				int X=u.x;
				int Y=u.y;
				REP(k,4) {
					int xx=X+dx[k];
					int yy=Y+dy[k];
					if(maze[xx][yy]=='.'&&!visit[xx][yy]) {
						q.push(node {xx,yy});
						step[xx][yy]=step[X][Y]+1;
						max_step=max(max_step,step[xx][yy]);
						visit[xx][yy]=true;
					}
				}
			}
		}
	}
	printf("%d",max_step);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:32: error: reference to 'visit' is ambiguous
   28 |                         memset(visit,0,sizeof(visit));
      |                                ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:8:6: note:                 'bool visit [21][21]'
    8 | bool visit[21][21];
      |      ^~~~~
a.cc:28:47: error: reference to 'visit' is ambiguous
   28 |                         memset(visit,0,sizeof(visit));
      |                                               ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:8:6: note:                 'bool visit [21][21]'
    8 | bool visit[21][21];
      |      ^~~~~
a.cc:40:64: error: reference to 'visit' is ambiguous
   40 |                                         if(maze[xx][yy]=='.'&&!visit[xx][yy]) {
      |                                                                ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:8:6: note:                 'bool visit [21][21]'
    8 | bool visit[21][21];
      |      ^~~~~
a.cc:44:49: error: reference to 'visit' is ambiguous
   44 |                                                 visit[xx][yy]=true;
      |                                                 ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:8:6: note:                 'bool visit [21][21]'
    8 | bool visit[21][21];
      |      ^~~~~