## 编译器上没问题 为什木编译失败 Why?
查看原帖
## 编译器上没问题 为什木编译失败 Why?
1092593
Cuimenghao楼主2024/5/22 14:19

编译器上没问题 为什木编译失败 Why?

#include<bits/stdc++.h>
using namespace std;
int ans[410][410];
struct horse {
	int x, y;
};
int n, m, mx, my;
queue<horse>que;
int mv[8][2] {{1, 2}, {2, 1}, {-1, 2}, {2, -1}, {-2, 1}, {1, -2}, {-1, -2}, {-2, -1}};
void uint() {
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			ans[i][j] = -1;
		}
	}
}
void print() {
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cout << ans[i][j] << "	";
		}
		cout << endl;
	}
}
int main() {
	cin >> n >> m >> mx >> my;
	horse l = {mx, my};
	que.push(l);
	uint();
	ans[mx][my] = 0;
	while (!que.empty()) {
		horse now = que.front();
		que.pop();
		for (int i = 0; i < 8; i++) {
			int nx = now.x + mv[i][0];
			int ny = now.y + mv[i][1];
			if (nx < 1 || nx > n || ny < 1 || ny > m || ans[nx][ny] != -1) {
				continue;
			}
			horse l = {nx, ny};
			ans[nx][ny] = ans[now.x][now.y] + 1;
		}
	}
	print();
	return 0;
}
2024/5/22 14:19
加载中...