Language: C++

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

struct grid{
	int X, Y;
}

char kotak[55][55];
bool visit[55][55];

int x1[4]={0, 1, 0, -1};
int y2[4]={1, 0, -1, 0};

queue<grid> pos;
int bfs(int EX, int EY)
{
	memset(visit, 0, sizeof(visit));
	while(!pos.empty())
	{
		pos.pop();
	}
	grid star; star.X=1; star.Y=1;
	pos.push(star);
	visit[1][1]=1;
	int moves=0;
	while(!pos.empty())
	{
		moves++;
		int p=pos.size();
		for(int x=0;x<p;x++)
		{
			int nowx=pos.front().X;
			int nowy=pos.front().Y;
			for(int z=0;z<4;z++)
			{
				int newx=nowx+x1[z];
				int newy=newy+y2[z];
				if(newx>0 && newy>0 && newx<=EX && newy<=EY && !visit[newy][newx] && kotak[newy][newx]=='.')
				{
					visit[newy][newx]=1;
					if(newy==EY && newx==newEX)
					{
						return moves;
					}
					grid nxt; nxt.X=newx; nxt.Y=newy;
					pos.push(nxt);
				}
			}
		}
	}
	return -1;
}

int main()
{
	int H, W;
	cin>>H>>W;
	int count=0;
	for(int a=1;a<=H;a++)
	{
		for(int b=1;b<=W;b++)
		{
			cin>>kotak[b][a];
			if((a==1 && b==1) || (a==H && b==W)) continue;
			if(kotak[b][a]=='.')
			{
				count++;
			}
		}
	}
	cout<<count-(bfs(W, H)-1);
	return 0;
}

Compiler output:
a.cc:6:2: error: expected ';' after struct definition
    6 | }
      |  ^
      |  ;
a.cc: In function 'int bfs(int, int)':
a.cc:17:16: error: reference to 'visit' is ambiguous
   17 |         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:9:6: note:                 'bool visit [55][55]'
    9 | bool visit[55][55];
      |      ^~~~~
a.cc:17:33: error: reference to 'visit' is ambiguous
   17 |         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:9:6: note:                 'bool visit [55][55]'
    9 | bool visit[55][55];
      |      ^~~~~
a.cc:24:9: error: reference to 'visit' is ambiguous
   24 |         visit[1][1]=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:9:6: note:                 'bool visit [55][55]'
    9 | bool visit[55][55];
      |      ^~~~~
a.cc:38:81: error: reference to 'visit' is ambiguous
   38 |                                 if(newx>0 && newy>0 && newx<=EX && newy<=EY && !visit[newy][newx] && kotak[newy][newx]=='.')
      |                                                                                 ^~~~~
/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:9:6: note:                 'bool visit [55][55]'
    9 | bool visit[55][55];
      |      ^~~~~
a.cc:40:41: error: reference to 'visit' is ambiguous
   40 |                                         visit[newy][newx]=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:9:6: note:                 'bool visit [55][55]'
    9 | bool visit[55][55];
      |      ^~~~~
a.cc:41:62: error: 'newEX' was not declared in this scope
   41 |                                         if(newy==EY && newx==newEX)
      |                                                              ^~~~~