![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
bfs
是Lr呀
这个作者很懒,什么都没留下…
展开
-
走迷宫的最少步数
#include<bits/stdc++.h>using namespace std;char a[41][41];int n,m,vis[41][41],ans;int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};bool check(int x,int y){ if(x>=1&&x<=n&&...原创 2020-03-29 16:09:56 · 1297 阅读 · 0 评论 -
最少步数
#include<bits/stdc++.h>using namespace std;int dir[12][2]={{-2,-1},{-2,1},{2,-1},{2,1},{-1,-2},{-1,2},{1,-2},{1,2},{-2,-2},{-2,2},{2,-2},{2,2}};struct pace{ int x,y,step;};int vis[101][10...原创 2020-03-29 15:36:20 · 526 阅读 · 0 评论 -
围成面积
思路:找到1外面的其中1一个0,把这个0bfs一遍全都变成1,最后遍历二维数组计算0的数量#include<bits/stdc++.h>using namespace std;int a[11][11],ans=0;int dis[4][2]={{1,0},{0,1},{0,-1},{-1,0}};bool check(int x,int y){ if(x>0&...原创 2020-03-15 17:42:25 · 422 阅读 · 0 评论 -
连通块
#include<bits/stdc++.h>using namespace std;int n,m,ans=0,a[120][120];int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};bool check(int x,int y){ if(x>0&&x<=n&&y>0&&...原创 2020-03-15 16:38:18 · 802 阅读 · 0 评论 -
奇怪的电梯
#include<bits/stdc++.h>using namespace std;struct seek{ int step,floor;};int main(){ int mark[310],k[310]; memset(mark,0,sizeof(mark)); queue<seek>lift; int n,beg,end; cin>&...原创 2020-03-14 22:59:08 · 178 阅读 · 0 评论 -
队列一个简单的例子
题目: 输入一个n*m的矩阵由0和1组成,1能通过,0不能,再输入起点的位置和终点的位置,求起点到终点的最短路径int put4 41 1 1 01 1 0 01 1 0 01 1 1 11 24 4out5#include<iostream>#include<queue>using namespace std;struct pace{ i...原创 2020-03-13 18:43:46 · 557 阅读 · 0 评论