2025考研b all ac

This commit is contained in:
2025-08-25 12:20:17 +08:00
parent 05b5349c93
commit a6ccb6431b

View File

@@ -53,16 +53,19 @@ int end_row, end_col;
int map[MAXN][MAXN] = {0};
// 0 = wall
// 1 = ground
// 2 = glass
bool valid_pos(int row, int col, posture pos) {
if (row >= n || col >= m || row < 0 || col < 0) {
return false;
}
if (pos == pos_s) {
return map[row][col] > 0;
return map[row][col] == 1;
} else if (pos == pos_h) {
if (col + 1 >= m) return false;
return map[row][col] > 0 && map[row][col + 1] > 0;
} else if (pos == pos_v) {
if (row + 1 >= n) return false;
return map[row][col] > 0 && map[row + 1][col] > 0;
} else {
// should not be here
@@ -287,8 +290,10 @@ int main() {
for (int j = 0; j < m; ++j) {
if (linebuf[j] == '#') {
map[i][j] = 0;
} else if (linebuf[j] == '.' || linebuf[j] == 'E') {
} else if (linebuf[j] == '.') {
map[i][j] = 1;
} else if (linebuf[j] == 'E') {
map[i][j] = 2;
} else if (linebuf[j] == 'X') {
map[i][j] = 1;
if (found_start == false) {