Language: C++

#include <bits/stdc++.h>
using namespace std;
char G[44][44];
int visit[44][44]={0};
int h,w;
int inbound(int i,int j){
    return i>0&&j>0&&i<=h&&j<=w&&G[i][j]=='.';
}
struct node{
    int a,b,c;
};
int a[4][2]={0,1,-1,0,0,-1,1,0};
int solve(int z,int c){
    int ret = 0 ;
    memset(visit,0,sizeof visit);

    queue<node>qq;
    qq.push({z,c,0});
    visit[z][c]=1;
    while(!qq.empty()){
        int x = qq.front().a;
        int y = qq.front().b;
        int len = qq.front().c;
        qq.pop();
        ret=max(ret,len);
        for(int i=0;i<4;i++){
            int x1= x+a[i][0];
            int y1= y+a[i][1];
            if(inbound(x1,y1)&&!visit[x1][y1]){
                visit[x1][y1]=1;
                qq.push({x1,y1,len+1});
            }
        }
    }
}
int main()
{

    cin  >> h>>w;
    for(int i=1;i<=h;i++){
        cin >>G[i]+1;
    }
    //visit[1][1]=1;
    int res = 0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++)
            res = max(res,solve(i,j));
    }
    cout << res <<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:15:12: error: reference to 'visit' is ambiguous
   15 |     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:4:5: note:                 'int visit [44][44]'
    4 | int visit[44][44]={0};
      |     ^~~~~
a.cc:15:27: error: reference to 'visit' is ambiguous
   15 |     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:4:5: note:                 'int visit [44][44]'
    4 | int visit[44][44]={0};
      |     ^~~~~
a.cc:19:5: error: reference to 'visit' is ambiguous
   19 |     visit[z][c]=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:4:5: note:                 'int visit [44][44]'
    4 | int visit[44][44]={0};
      |     ^~~~~
a.cc:29:33: error: reference to 'visit' is ambiguous
   29 |             if(inbound(x1,y1)&&!visit[x1][y1]){
      |                                 ^~~~~
/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:4:5: note:                 'int visit [44][44]'
    4 | int visit[44][44]={0};
      |     ^~~~~
a.cc:30:17: error: reference to 'visit' is ambiguous
   30 |                 visit[x1][y1]=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:4:5: note:                 'int visit [44][44]'
    4 | int visit[44][44]={0};
      |     ^~~~~
a.cc:35:1: warning: no return statement in function returning non-void [-Wreturn-type]
   35 | }
      | ^