Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <iostream>#include <queue>#include <climits>using namespace std;const int MAXN = 100;char board[MAXN][MAXN];int dist[MAXN][MAXN];int m, n, hi, hj, min_dist = INT_MAX;void check(int i, int j, int nd, bool isS, queue<pair<int, int>>& q) {if (i < 0 || i >= n || j < 0 || j >= m) return;if (board[i][j] == 'P' || board[i][j] == '#') return;if (isS && board[i][j] == 'S') {if (dist[i][j] != INT_MAX) {min_dist = min(min_dist, dist[i][j] + nd);}} else if (!isS){if (dist[i][j] == INT_MAX) {dist[i][j] = nd + 1;q.push({i, j});}}}void bfs() {queue<pair<int, int>> q;dist[hi][hj] = 0;q.push({hi, hj});while (!q.empty()) {