Language: C++

#include<bits/stdc++.h>
using namespace std;
bool visit[100][100];
int fx[] = {0,0,1,-1};
int fy[] = {1,-1,0,0};
int dist[100][100];
int main()
{
    int n,m;
    cin >> n >> m ;
    char ara[n+10][m+10];

    int cnt = 0;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            cin >> ara[i][j] ;
            dist[i][j] = INT_MAX;
            if(ara[i][j]=='.')cnt++;
        }
    }
   // cout << cnt << " " << n*m << endl;

   // memset(dist,2,sizeof dist);


    queue <pair<int,int> > q;
    bool mrk = 0;
    if(ara[0][0]=='.' && ara[n-1][m-1]=='.')
    q.push({0,0}),dist[0][0] = 0,visit[0][0]=0;
    else mrk = 1;

    //cout << dist[n-1][m-1] << endl;
    if(!mrk)
    while(!q.empty())
    {
        pair<int,int> prnt = q.front() ;
        q.pop();
        int px = prnt.first;
        int py = prnt.second;
        for(int i=0; i<4; i++)
        {

            int cx = px + fx[i];
            int cy = py + fy[i];

            if(cx>=0 && cx<n && cy>=0 && cy<m && ara[cx][cy]=='.'  && visit[cx][cy]==0)
            {
                visit[cx][cy] = 1;
    //            cout << px << " " << py << endl;
      //          cout << cx << " " << cy << endl;
                dist[cx][cy] = dist[px][py]+1 ;
                q.push({cx,cy});
            }
        }

    }

    int rasta = 0 ;
    if(!mrk)
     rasta =  dist[n-1][m-1]+1 ;
      if(!mrk)
      cout << cnt - rasta << endl;
      else cout << "-1" << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:34: error: reference to 'visit' is ambiguous
   31 |     q.push({0,0}),dist[0][0] = 0,visit[0][0]=0;
      |                                  ^~~~~
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:3:6: note:                 'bool visit [100][100]'
    3 | bool visit[100][100];
      |      ^~~~~
a.cc:48:71: error: reference to 'visit' is ambiguous
   48 |             if(cx>=0 && cx<n && cy>=0 && cy<m && ara[cx][cy]=='.'  && visit[cx][cy]==0)
      |                                                                       ^~~~~
/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:3:6: note:                 'bool visit [100][100]'
    3 | bool visit[100][100];
      |      ^~~~~
a.cc:50:17: error: reference to 'visit' is ambiguous
   50 |                 visit[cx][cy] = 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:3:6: note:                 'bool visit [100][100]'
    3 | bool visit[100][100];
      |      ^~~~~