Language: C++

#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int visit[1200][1200],dis[1200][1200];
int R,C;
int row[]= {1,0,-1,0,1,-1,1,-1};
int colm[]= {0,1,0,-1,1,-1,-1,1};
string maze[200];
void bfs(int input_x,int input_y)
{
    queue<pair<int,int> >q;
    visit[input_x][input_y] = 1;
    dis[input_x][input_y]   = 0;
    q.push(make_pair(input_x,input_y));
    while(!q.empty())
    {
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        for(int i=0; i<4; i++)
        {
            int u = x+row[i];
            int v = y+colm[i];
            if(0<=u && u<R && 0<=v && v<C)
            {
                if(visit[u][v]==0 && maze[u][v]=='.')
                {
                    visit[u][v]=1;
                    dis[u][v] = dis[x][y]+1;
                    q.push(make_pair(u,v));
                }
            }
        }
    }
    return ;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    cin>>R>>C;
    for(int i=0; i<R; i++)
        cin>>maze[i];
    bfs(0,0);
    int cnt=0;
    for(int i=0; i<R; i++)
    {
        for(int j=0; j<C; j++)
        {
            if(maze[i][j]=='.')
                cnt++;
        }
    }
    if(dis[R-1][C-1]==0){
        cout<<"-1"<<endl;
    }
    else{
        cout<<cnt-dis[R-1][C-1]-1<<endl;
    }

    return 0;
}


Compiler output:
a.cc: In function 'void bfs(int, int)':
a.cc:22:5: error: reference to 'visit' is ambiguous
   22 |     visit[input_x][input_y] = 1;
      |     ^~~~~
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:14:5: note:                 'int visit [1200][1200]'
   14 | int visit[1200][1200],dis[1200][1200];
      |     ^~~~~
a.cc:36:20: error: reference to 'visit' is ambiguous
   36 |                 if(visit[u][v]==0 && maze[u][v]=='.')
      |                    ^~~~~
/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:14:5: note:                 'int visit [1200][1200]'
   14 | int visit[1200][1200],dis[1200][1200];
      |     ^~~~~
a.cc:38:21: error: reference to 'visit' is ambiguous
   38 |                     visit[u][v]=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:14:5: note:                 'int visit [1200][1200]'
   14 | int visit[1200][1200],dis[1200][1200];
      |     ^~~~~