文章
99
粉丝
120
获赞
8
访问
96.8k
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
#define inf 0x3f3f3f3f
#define maxn 110
struct node {
int x, y;
};
int n, m;
node p[4];
char mpt[maxn][maxn];
int vis[maxn][maxn][4];//vis分别代表每个人到每一个点需要消掉的障碍物
int dir[4][2] = { 1, 0, -1, 0, 0, 1, 0, -1 };
void bfs(int index)
{
queue<node> q;
node now, next;
now.x = p[index].x;
now.y = p[index].y;
q.push(now);
vis[now.x][now.y][index] = 0;
while (!q.empty()) {
now = q.front();
q.pop();
for (int i = 0; i < 4; i++) {
next = now;
next.x += dir[i][0];
next.y += dir[i][1];
if (next.x<1 || next.x>n || next.y<1 || next.y>m) continue;
int tmp = vis[now.x][now.y][index];
if (mpt[next.x][next.y] == '#')tmp++;//遇到一个障碍物,那么此人到达这个点需要消掉的障碍物加1
if (tmp < vis[next.x][next.y][index]) {...
登录后发布评论
暂无评论,来抢沙发