Language: C++

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

struct node{
    int x,y;
    node(){}
    node(int a,int b):x(a),y(b){}
};
char mp[100][100];
int minn,h,w;
int visit[100][100];
int step[100][100];
int next[4][2]={{0,-1},{-1,0},{0,1},{1,0}};
queue<node>q;

int main(){
    int sum=0,flag=0;
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++){
        getchar();
        for(int j=0;j<w;j++){
            scanf("%c",&mp[i][j]);
            if(mp[i][j]=='#') sum++;
        }
    }
    visit[0][0]=1;
    q.push(node(0,0));
    while(!q.empty()){
        if(flag) break;
        int tx=q.front().x;
        int ty=q.front().y;
        q.pop();
        for(int i=0;i<4;i++){
            int xx=tx+next[i][0];
            int yy=ty+next[i][1];
            if(xx<0||xx>=h||yy<0||yy>=w) continue;
            if(xx==h-1&&yy==w-1)  flag=step[tx][ty]+1;
            if(visit[xx][yy]==0&&mp[xx][yy]=='.'){
                visit[xx][yy]=1;
                q.push(node(xx,yy));
                step[xx][yy]=step[tx][ty]+1;
            }
        }
    }


    printf("%d\n",h*w-flag-sum-1);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:5: error: reference to 'visit' is ambiguous
   26 |     visit[0][0]=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:11:5: note:                 'int visit [100][100]'
   11 | int visit[100][100];
      |     ^~~~~
a.cc:34:23: error: reference to 'next' is ambiguous
   34 |             int xx=tx+next[i][0];
      |                       ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:13:5: note:                 'int next [4][2]'
   13 | int next[4][2]={{0,-1},{-1,0},{0,1},{1,0}};
      |     ^~~~
a.cc:35:23: error: reference to 'next' is ambiguous
   35 |             int yy=ty+next[i][1];
      |                       ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:13:5: note:                 'int next [4][2]'
   13 | int next[4][2]={{0,-1},{-1,0},{0,1},{1,0}};
      |     ^~~~
a.cc:38:16: error: reference to 'visit' is ambiguous
   38 |             if(visit[xx][yy]==0&&mp[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:11:5: note:                 'int visit [100][100]'
   11 | int visit[100][100];
      |     ^~~~~
a.cc:39:17: error: reference to 'visit' is ambiguous
   39 |                 visit[xx][yy]=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:11:5: note:                 'int visit [100][100]'
   11 | int visit[100][100];
      |     ^~~~~