80pts求助,WA#4#5

P3818 小A和uim之大逃离 II

```cpp #include <bits/stdc++.h> using namespace std; const int N = 1010; struct node { int x, y, step; bool yao; }tmp; inline int read() { int s = 0, w = 1;char ch = getchar(); while(ch < '0' || ch > '9'){if(ch == '-') w = -1;ch = getchar();} while(ch >= '0' && ch <= '9'){s = s * 10 + ch - '0'; ch = getchar();} return s * w; } int dx[5] = {0, 0, 1, -1, 0}; int dy[5] = {0, 1, 0, 0, -1}; char mp[N][N];int n, m, d, r;bool vis[N][N]; queue <node> q; bool check(int x, int y) { return x >= 1 && x <= n && y >= 1 && y <= m&& mp[x][y] != '#' && ! vis[x][y]; } void bfs() { while(!q.empty()) { node t = q.front(); q.pop(); for(int i = 1;i <= 4;i ++) { int x = t.x + dx[i], y = t.y + dy[i]; if(check(x, y)) { vis[x][y] = true; tmp.x = x, tmp.y = y; tmp.step = t.step + 1; q.push(tmp); if(tmp.x == n && tmp.y == m) { cout << tmp.step << endl; exit(0); } if(! t.yao) { tmp.x = x + d, tmp.y = y + r; if(check(tmp.x, tmp.y)) { tmp.yao = true; tmp.step ++; q.push(tmp); if(tmp.x == n && tmp.y == m) { cout << tmp.step << endl; exit(0); } } } } } } } int main() { n = read(), m = read(), d = read(), r = read(); for(int i = 1;i <= n;i ++) for(int j = 1;j <= m;j ++) cin >> mp[i][j]; tmp.x = 1, tmp.y = 1, tmp.step = 0; q.push(tmp); bfs(); cout << -1 << endl; return 0; } ```
by Killua_Zaoldyeck @ 2023-02-24 18:32:05


蒟蒻在此表示无能为力
by LeiZeProMax @ 2023-02-24 18:36:29


@[LeiZe](/user/649222) 。。
by Killua_Zaoldyeck @ 2023-02-24 18:38:15


(闲逛
by RAMN @ 2023-02-24 19:17:56


@[RAMN](/user/726824) .
by Killua_Zaoldyeck @ 2023-02-24 19:19:09


小可也是80分 和你错的一样
by Wyy_w123 @ 2023-04-05 15:12:51


=叫點人過來()
by Wyy_w123 @ 2023-04-07 21:54:30


g^u~~
by Wyy_w123 @ 2023-04-07 21:54:57


@[weizibao](/user/722728)
by Wyy_w123 @ 2023-04-07 21:56:38


@[Wf_yjqd](/user/526094)
by Wyy_w123 @ 2023-04-07 21:58:07


| 下一页