Language: C++

// ConsoleApplication20.cpp : アプリケーションのエントリ ポイントを定義します。
//


#include <queue>
#include <utility>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<string>
#include<cmath>
#include<cstring>
#include<vector>
typedef pair<int, int> P;
const int INF = 100000000;
char maze[51][51];
int d[50][50];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int bfs(int H,int W) {
	int i, j, k, l, m, nx, ny;
	queue<P> que;
	for (i = 0; i < 50; i++) {
		for (j = 0; j < 50; j++) {
			d[i][j] = INF;
		}
	}
	que.push(P(0, 0));
	d[0][0] = 0;
	while (que.size()) {
		P p = que.front();
		que.pop();
		if (p.first == 49 && p.second == 49)
			break;
		for (i = 0; i < 4; i++) {
			nx = p.first + d[x];
			ny = p.second + d[y];

			if (nx >= 0 && nx < H&&ny >= 0 && ny < W&&d[nx][ny] == INF && maze[nx][ny] != '#') {
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[W-1][H-1];
}



int main()
{
	int H, W;
	cin >> H >> W;
	int i, j, k;
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			cin >> maze[i][j];
		}
	}
	k = bfs(H, W);
	if (k = INF)
		cout << "-1" << endl;
	else
		cout << H * W - k << endl;
    return 0;
}



Compiler output:
a.cc:14:9: error: 'pair' does not name a type
   14 | typedef pair<int, int> P;
      |         ^~~~
a.cc: In function 'int bfs(int, int)':
a.cc:23:9: error: 'queue' was not declared in this scope; did you mean 'std::queue'?
   23 |         queue<P> que;
      |         ^~~~~
      |         std::queue
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here
   96 |     class queue
      |           ^~~~~
a.cc:23:15: error: 'P' was not declared in this scope
   23 |         queue<P> que;
      |               ^
a.cc:23:18: error: 'que' was not declared in this scope
   23 |         queue<P> que;
      |                  ^~~
a.cc:32:18: error: expected ';' before 'p'
   32 |                 P p = que.front();
      |                  ^~
      |                  ;
a.cc:34:21: error: 'p' was not declared in this scope
   34 |                 if (p.first == 49 && p.second == 49)
      |                     ^
a.cc:37:30: error: 'p' was not declared in this scope
   37 |                         nx = p.first + d[x];
      |                              ^
a.cc:37:42: error: 'x' was not declared in this scope; did you mean 'nx'?
   37 |                         nx = p.first + d[x];
      |                                          ^
      |                                          nx
a.cc:38:43: error: 'y' was not declared in this scope; did you mean 'ny'?
   38 |                         ny = p.second + d[y];
      |                                           ^
      |                                           ny
a.cc: In function 'int main()':
a.cc:54:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   54 |         cin >> H >> W;
      |         ^~~
      |         std::cin
In file included from a.cc:8:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:63:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   63 |                 cout << "-1" << endl;
      |                 ^~~~
      |                 std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:63:33: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   63 |                 cout << "-1" << endl;
      |                                 ^~~~
      |                                 std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:65:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   65 |                 cout << H * W - k << endl;
      |                 ^~~~
      |                 std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:65:38: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   65 |                 cout << H * W - k << endl;
      |                                      ^~~~
      |                                      std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~