Language: C++

#include <stdio.h>
#include <queue>
#include <utility>



int main(void){
	int h, w, i, j;
	int gx, gy, nx, ny;
	const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}, INF = 0x7FFFFFFF;
	char maze[59][60];
	int sl[59][59];
	pair<int,int> p;
	queue<pair<int,int>> que;

	scanf("%d%d%*c",&w,&h);

	while(h != 0 || w != 0){

		for(i = 0;i < 2 * h - 1;i++){
			for(j = 0;j < 2 * w - 1;j++)
				maze[i][j] = getchar();
			getchar();
		}

		for(i = 0;i < 2 * h - 1;i++){
			for(j = 0;j < 2 * w - 1;j++)
				sl[i][j] = INF;
		}
		sl[0][0] = 1;
		que.push(pair<int,int>(0,0));
		gx = 2 * w - 2; gy = 2 * h - 2;
		while(que.size()){
			p = que.front(); que.pop();
			if(p.first == gx && p.second == gy)
				break;
			for(i = 0;i < 4;i++){
				nx = p.first + 2 * dx[i]; ny = p.second + 2 * dy[i];
				if(0 <= nx && nx < 2 * w - 1 && 0 <= ny && ny < 2 * h - 1 && sl[ny][nx] == INF && maze[p.second + dy[i]][p.first + dx[i]] == '0'){
					que.push(pair<int,int>(nx,ny));
					sl[ny][nx] = sl[p.second][p.first] + 1;
				}
			}
		}
		while(que.size())
			que.pop();
		if(sl[gy][gx] == INF)
			printf("0\n");
		else
			printf("%d\n",sl[gy][gx]);
		scanf("%d%d%*c",&w,&h);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   13 |         pair<int,int> p;
      |         ^~~~
      |         std::pair
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/deque:62,
                 from /usr/include/c++/14/queue:62,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: 'std::pair' declared here
   89 |     struct pair;
      |            ^~~~
a.cc:13:14: error: expected primary-expression before 'int'
   13 |         pair<int,int> p;
      |              ^~~
a.cc:14:9: error: 'queue' was not declared in this scope; did you mean 'std::queue'?
   14 |         queue<pair<int,int>> que;
      |         ^~~~~
      |         std::queue
In file included from /usr/include/c++/14/queue:66:
/usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here
   96 |     class queue
      |           ^~~~~
a.cc:14:20: error: expected primary-expression before 'int'
   14 |         queue<pair<int,int>> que;
      |                    ^~~
a.cc:31:17: error: 'que' was not declared in this scope
   31 |                 que.push(pair<int,int>(0,0));
      |                 ^~~
a.cc:31:31: error: expected primary-expression before 'int'
   31 |                 que.push(pair<int,int>(0,0));
      |                               ^~~
a.cc:31:35: error: expected primary-expression before 'int'
   31 |                 que.push(pair<int,int>(0,0));
      |                                   ^~~
a.cc:34:25: error: 'p' was not declared in this scope
   34 |                         p = que.front(); que.pop();
      |                         ^
a.cc:40:55: error: expected primary-expression before 'int'
   40 |                                         que.push(pair<int,int>(nx,ny));
      |                                                       ^~~
a.cc:40:59: error: expected primary-expression before 'int'
   40 |                                         que.push(pair<int,int>(nx,ny));
      |                                                           ^~~