![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
搜索
dfs bfs 剪枝
我要找对象
这个作者很懒,什么都没留下…
展开
-
DFS最最最基础题1
DFS最最最基础题1 1.水洼数目 题目 有一个大小为 NM 的园子,雨后积起了水。八连通的积水被认为是连接在一起的。请求出 园子里总共有多少水洼?(八连通指的是下图中相对 W 的的部分) *** *W* *** 限制条件 N, M ≤ 100 样例: 输入 N=10, M=12 园子如下图('W’表示积水, '.'表示没有积水) 10 12 W........WW. .WWW.....WWW ....WW...WW. .........WW. .........W.. ..W......W..原创 2020-10-22 11:42:19 · 230 阅读 · 2 评论 -
第五天 dfs
第五天 dfs 1 题解 #include<iostream> #include<cstdio> using namespace std; char s[10][10]; bool f; bool vis[10][10]; int dir[8][2] = {{2,1},{1,2},{-1,2},{-2,1},{-2,-1},{-1,-2},{1,-2},{2,-1}}; bool in(int x,int y){ return 0<=x && x<原创 2020-10-21 12:33:38 · 142 阅读 · 0 评论 -
第八天 bfs
第八天 bfs 题 1 迷宫最短路问题 ———————————— 题解 #include<iostream> #include<cstdio> #include<queue> using namespace std; struct node{ int x,y,d; node(int xx,int yy,int dd){ x = xx; y = yy; d = dd; } }; int dir[4][2] = {{-1,0},{0,-1},{1,0},{0原创 2020-10-20 18:39:11 · 77 阅读 · 0 评论 -
第六天 dfs
第六天 dfs 1 8皇后 题解 #include<iostream> #include<cstdio> using namespace std; int ans = 0; bool col[10],x1[20],x2[20]; bool check(int r,int i){ return !col[i] && !x1[r+i] && !x2[r-i+8]; } void dfs(int r){ if(r == 8){ ans++; re原创 2020-07-19 21:56:08 · 90 阅读 · 0 评论