随笔分类 - bfs
搜索
摘要:链接:https://www.acwing.com/problem/content/1115/ 代码: bfs: #include<iostream> #include<algorithm> #include<queue> using namespace std; char s[25][25]; i
阅读全文
摘要:链接:https://www.acwing.com/problem/content/1098/ 思路:1:三维bfs:可以分为当前层数内的二维内偏移和层数的一维偏移 代码: #include<iostream> #include<queue> #include<string> #include<cs
阅读全文
摘要:链接:https://www.acwing.com/problem/content/1235/ 代码: #include<bits/stdc++.h> using namespace std; int k=0,n; char s[1005][1005]; int b[1005][1005]; int
阅读全文
摘要:题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805392092020736 题意:计算一个图中距离某个点k层以内的点的个数 思路:BFS计算层数 层数只能由上一层得到:next.layer=last.layer
阅读全文