@[Fruit_candy](/user/365597) 真巧,我也是[捂脸]
by Jasonde1024 @ 2023-07-14 20:33:37
我现在调好了,你应该加一个used数组标记之前走过的路,防止重复。我这么做就AC了
by Jasonde1024 @ 2023-07-14 20:37:12
```c++
for (int i = 0; i < 4; ++i) {
int newx = x+dx[i];
int newy = y+dy[i];
if (newx > 0 && newx <= n && newy > 0 && newy <= n) {
if (used[newx][newy]) continue;
if (map[newx][newy] == '0') {
q.push(newx);
q.push(newy);
q.push(r+1);
used[newx][newy] = 1;
}
}
}
```
by Jasonde1024 @ 2023-07-14 20:38:12