为什么top.x加的是纵坐标对应的数组top.y加的是横坐标
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 2e3 + 5;
const int INF = 0x7f7f7f7f;
struct Node {
int x;
int y;
} node;
int a[N][N],p[N][N];
int b[3] = {-1,1,0};
int c[3] = {0,0,1};
int n,m;
int bfs() {
queue<Node> qu;
node.x = 1;
node.y = 1;
qu.push(node);
while(!qu.empty()) {
Node top = qu.front();
qu.pop();
for(int i = 0; i < 3; i++) {
int newx = top.x + b[i];
int newy = top.y + c[i];
if(newx < 1 || newx > n || newy < 1 || newy > m)
continue;
int d = (a[top.x][top.y] == a[newx][newy] ? 1 : 2);
if(p[newx][newy] > p[top.x][top.y] + d) {
p[newx][newy] = p[top.x][top.y] + d;
node.x = newx;
node.y = newy;
qu.push(node);
}
}
}
return p[n][m];
}
int main() {
IOS
cin >> n >> m;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
cin >> a[i][j];
memset(p,0x3f,sizeof(p));
p[1][1] = 0;
cout << bfs();
return 0;
}