文章
10
粉丝
0
获赞
89
访问
8.8k
 
#include<iostream>
#include<queue>
#include<cstring>
//PII表示坐标
typedef std::pair<int, int> PII;
int H, W;
char map[110][110];
//向左,向右,向上,向下
int dx[] = { -1,1,0,0 };
int dy[] = { 0,0,1,-1 };
int distance[110][110];
int bfs(int startX, int startY) {
    std::queue<PII> q;
    distance[startX][startY] = 0;
    q.push({ startX,startY });
    while (q.size()) {
        auto pii = q.front();
        q.pop();
        int x = pii.first;
        int y = pii.second;
        for (int i = 0; i < 4; i++)
        {
            //把上下左右四个方向符合条件的压进队列
            // 不是#且坐标没有越界而且还没有被访问过
       &...
登录后发布评论
暂无评论,来抢沙发