首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
成功保外的小孙
2021年8月21日 16:06
典型bfs
P1563
回复 1
|
赞 7
|
浏览 7.8k
题解不仅面向了多个出口,对于多入多出也可以应用 典型的bfs解法,利用队列和判别条件入队出队 为了加速算法,讨论了无入口/无出口的情况,直接输出 代码略微麻烦的地方在于找不到路径的情况,反复用了break和continue,若有改进请各位大佬指点 #include<iostream> #include<queue> using namespace std; typedef pair<int, int> PII; const int N = 105; int h, w; int main() { ...
Cookie‘s AE86
2024年3月17日 20:31
迷宫 题解:一道题写了一下午(b站找视频学+自己码+各种debug),
P1563
回复 1
|
赞 0
|
浏览 1.1k
#include<bits/stdc++.h> using namespace std; struct item{ int i; int j; int step; char date; }; //存储广度优先遍历的每一步节点信息 char mp[110][110]; void bfs(int h, int w); int main(){ int h, w; while(cin >> h >> w){ if(h == 0...
xx_about123456
2022年8月10日 09:13
迷宫BFS
P1563
回复 0
|
赞 5
|
浏览 6.0k
利用队列进行广度优先遍历(已经遍历过的需要做标记,尤其是跟结点) 借助方向数组,遍历4个方向,符合条件,入队 遍历到终点,退出判断(如果不可能到终点,返回-1,所以设置ans初始值为-1) 代码 #include<bits/stdc++.h> using namespace std; const int maxn = 100+5; char mpt[maxn][maxn]; int vis[maxn][maxn]; int dir[4][2] = {0,1,1,0,0,-1,-1,0}; struct node { ...
青缘
2022年7月17日 15:55
1563 迷宫 南开大学2019年机试题 AC
P1563
回复 0
|
赞 13
|
浏览 6.4k
此题为一个经典的简单模板BFS 确定思路过程如下: 迷宫问题--->使用搜索算法 存在多个终点时,要去输出最短的一条路--->使用BFS 相比于最纯粹的BFS,这题考察的点在于: 如何使用一个dis[x][y]二维数组去记录走到点(x,y)的步数 代码如下: // 迷宫问题,最短到达终点路径,宽度优先搜索 #include <bits/stdc++.h> using namespace std; char G[105][105]; ...
shmilyzsc
2021年2月23日 14:20
BFS
P1563
回复 0
|
赞 1
|
浏览 8.0k
#include <bits/stdc++.h> using namespace std; #define x first #define y second const int N = 100 + 5; typedef pair<int, int> PII; char g[N][N]; int d[N][N]; int dx[4] = {-1,0,1,0}, dy[4] = {0,-1,0,1}; int h, m; int bfs(int sx, int sy) { queue<PII> q; d[s...
James
2021年2月2日 15:24
注意有多个出口
P1563
回复 0
|
赞 2
|
浏览 9.8k
#include<iostream> #include<string.h> #include<queue> using namespace std; struct node{ int x,y; int step; }; queue <node> q; int map[105][105]; int out[105][105]; int dx[4]={0,0,1,-1}; int dy[4]={1,-1,0,0}; int h,...
wksby
2020年3月26日 21:06
bfs
P1563
回复 0
|
赞 2
|
浏览 9.7k
#include<iostream> #include<vector> #include<queue> #include<cstdio> using namespace std; int hang[4]={-1,1,0,0}; //上下左右四个方向 int lie[4]={0,0,-1,1}; int bfs(vector<vector<char> >&G,vector<vector<bool> >&vis,int x,int y,int h,int w){ ...
1
2
题目
迷宫
题解数量
17
发布题解
在线答疑
热门题解
1
迷宫(C++11 bfs宽搜 附详细注释) 题解:
2
BFS无权图
3
迷宫 题解:
4
1563 迷宫 南开大学2019年机试题 AC
5
迷宫 题解:我自己跑都没啥问题,为什么在这就runtime error?
6
迷宫 题解:简单说两个问题
7
迷宫 题解:
8
典型bfs
9
迷宫BFS
10
迷宫 题解: