Language: C++

#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
bool same[52][52][52][52] = { 0 };
queue<maigo> q;
struct maigo{
	int x[2];// ????????????[0]???????????????[1]
	int y[2];// ????????????[0]???????????????[1]
	int count;
};
int main(){
	int tx, ty; int kx, ky;
	int **depart, X, Y;
	int flag = 0, a = 0;
	int c = 0;
	int f = 0;
	cin >> X >> Y;
	while (X != 0 && Y != 0){
		depart = new int*[Y + 2];
		for (int i = 0; i < Y + 2; i++){
			depart[i] = new int[X + 2];
		}
		for (int i = 0; i < Y + 2; i++){
			for (int l = 0; l < X + 2; l++){
				depart[i][l] = 3;
			}
		}
		cin >> tx >> ty;
		cin >> kx >> ky;
		for (int i = 1; i < Y + 1; i++){
			for (int l = 1; l < X + 1; l++){
				cin >> depart[i][l];
			}
		}
		maigo temp;
		temp.x[0] = tx; temp.y[0] = ty;
		temp.x[1] = kx; temp.y[1] = ky;
		temp.count = 1;
		q.push(temp);
		while (!q.empty() && flag == 0){
			maigo t = q.front();
			maigo into;
			q.pop();
			same[t.x[0]][t.y[0]][t.x[1]][t.y[1]] = 1;
			if (t.count >= 100) break;
			int dx1[4] = { 1, 0, -1, 0 }; int dx2[4] = { 0, 1, 0, -1 };
			for (int i = 0; i < 4; i++){
				if (depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] == 0 &&
					depart[t.x[1] - dx1[i]][t.y[1] - dx2[i]] == 0 &&
					same[t.x[0] + dx1[i]][t.y[0] + dx2[i]][t.x[1] - dx1[i]][t.y[1] - dx2[i]] == 0){
					if (t.x[0] + dx1[i] == t.x[1] - dx1[i] &&
						t.y[0] + dx2[i] == t.y[1] - dx2[i]){
						cout << t.count << endl;
						flag = 1;
					}
					into.x[0] = t.x[0] + dx1[i], into.y[0] = t.y[0] + dx2[i];
					into.x[1] = t.x[1] - dx1[i], into.y[1] = t.y[1] - dx2[i];

					into.count = t.count + 1;
					q.push(into);
				}
				if (depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] == 0 && //???????????? ok ???????????? no ?????´???
					depart[t.x[1] - dx1[i]][t.y[1] - dx2[i]] != 0 &&
					same[t.x[0] + dx1[i]][t.y[0] + dx2[i]][t.x[1]][t.y[1]] == 0){
					if (t.x[0] + dx1[i] == t.x[1] &&
						t.y[0] + dx2[i] == t.y[1]){
						cout << t.count << endl;
						flag = 1;
					}
					into.x[0] = t.x[0] + dx1[i], into.y[0] = t.y[0] + dx2[i];
					into.x[1] = t.x[1], into.y[1] = t.y[1];

					into.count = t.count + 1;
					q.push(into);
				}
				if (depart[t.x[0] + dx1[i]][t.y[0] + dx2[i]] != 0 && //???????????? no??????????????? yes????????´???
					depart[t.x[1] - dx1[i]][t.y[1] - dx2[i]] == 0 &&
					same[t.x[0]][t.y[0]][t.x[1] - dx1[i]][t.y[1] - dx2[i] == 0]){
					if (t.x[0] == t.x[1] - dx1[i] &&
						t.y[0] == t.y[1] - dx2[i]){
						cout << t.count << endl;
						flag = 1;
					}
					into.x[0] = t.x[0], into.y[0] = t.y[0];
					into.x[1] = t.x[1] - dx1[i], into.y[1] = t.y[1] - dx2[i];
					into.count = t.count + 1;
					q.push(into);
				}
			}
		}if (flag == 0) {
			cout << "NA" << endl;
		}while (!q.empty()) q.pop();
		flag = 0;
		fill(same[0][0][0], same[52][0][0], 0);
		cin >> X >> Y;
	}
	return 0;
}

Compiler output:
a.cc:6:7: error: 'maigo' was not declared in this scope
    6 | queue<maigo> q;
      |       ^~~~~
a.cc:6:12: error: template argument 1 is invalid
    6 | queue<maigo> q;
      |            ^
a.cc:6:12: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:40:19: error: request for member 'push' in 'q', which is of non-class type 'int'
   40 |                 q.push(temp);
      |                   ^~~~
a.cc:41:27: error: request for member 'empty' in 'q', which is of non-class type 'int'
   41 |                 while (!q.empty() && flag == 0){
      |                           ^~~~~
a.cc:42:37: error: request for member 'front' in 'q', which is of non-class type 'int'
   42 |                         maigo t = q.front();
      |                                     ^~~~~
a.cc:44:27: error: request for member 'pop' in 'q', which is of non-class type 'int'
   44 |                         q.pop();
      |                           ^~~
a.cc:61:43: error: request for member 'push' in 'q', which is of non-class type 'int'
   61 |                                         q.push(into);
      |                                           ^~~~
a.cc:75:43: error: request for member 'push' in 'q', which is of non-class type 'int'
   75 |                                         q.push(into);
      |                                           ^~~~
a.cc:88:43: error: request for member 'push' in 'q', which is of non-class type 'int'
   88 |                                         q.push(into);
      |                                           ^~~~
a.cc:93:28: error: request for member 'empty' in 'q', which is of non-class type 'int'
   93 |                 }while (!q.empty()) q.pop();
      |                            ^~~~~
a.cc:93:39: error: request for member 'pop' in 'q', which is of non-class type 'int'
   93 |                 }while (!q.empty()) q.pop();
      |                                       ^~~