文章
59
粉丝
0
获赞
317
访问
7.2k
#include <iostream>
#include <deque>
#include <cstring>
#include <utility>
using namespace std;
const int maxn = 100 + 5;
const int INF = 1e9;
// 迷宫字符图
char mpt[maxn][maxn];
// 三个人分别跑出来的最小“拆墙数”距离
int dista[3][maxn][maxn];
// 方向数组
const int mov[4][2] = { {0,1},{1,0},{0,-1},{-1,0} };
// 0-1 BFS:走到 '.'/'w'/'W'/'f' 代价 0;走到 '#' 代价 1
// id = 0/1/2 分别表示从 w / W / f 出发
void bfs01(int sx, int sy, int id, int n, int m)
{
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
dista[id][i][j] = INF;
deque<pair<int,int> > dq;
dista[id][sx][sy] = 0;
dq.push_front(make_pair(sx, sy));
while (!dq.empty())
{
pair<int,int> cur = dq.front();
dq.pop_front();
int x = cur.first;
int y = cur.second;
for (int k = 0; k < 4; k++)
{
int nx = x + mov[k][0];
int ny = y + mov[k][1];
if...
登录后发布评论
暂无评论,来抢沙发