![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
搜索
精神小伙mqpm
这个作者很懒,什么都没留下…
展开
-
poj2251广搜 三维
You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south, east, west, up or down. You cannot move diagonally an.原创 2020-09-01 15:31:14 · 102 阅读 · 0 评论 -
poj1016素数环
题意 : 给一个n 给出由1到n的书组成的环两两相加是素数用dfs搜索 i表示当前数字 len表示深度 成环还要满足数组收尾相加是素数代码:#include<bits/stdc++.h>using namespace std;int n;int a[21];int vis[21];bool is_prime(int a){ if(a == 1) return false; for(int i = 2; i*i <= a; i++)原创 2020-08-20 19:00:40 · 107 阅读 · 0 评论 -
cf997D dfs
按题意搜索即可代码:#include<bits/stdc++.h>#define LL long longusing namespace std;int n;LL a[101];LL ans[101];map<LL , int> vis;int flag = 0;void opt(){ for(int i = 0; i < n; i++){ if(i != 0) cout << ' ' ; cout &原创 2020-08-20 18:57:44 · 156 阅读 · 0 评论 -
POJ - 1321 DFS
题意 : 在给定的棋盘上放子 求方案数思路 :dfs 见注释代码:#include <bits/stdc++.h>using namespace std;const int maxn = 9;int n, k;int vis[maxn];int total;char mp[maxn][maxn];void dfs(int row, int num){ if ( num == k ){ //满足条件 total++; return; } if ( row .原创 2020-08-14 20:30:37 · 100 阅读 · 0 评论 -
D - Lake Counting POJ - 2386
dfs的练手题 遍历找到W就搜索与他相连的W变成点并计数代码:#include<iostream>#include<cstring>#include<cstdio>using namespace std;int N;int M;int sum = 0;char p[101][101];bool ok(int i, int j){ if(i >= 0 && i < N && j >= 0 &a.原创 2020-08-19 23:25:17 · 108 阅读 · 0 评论 -
HDU 1242【DFS/BFS】
最短路的问题 踩了好多坑用的dfs出现的问题 :1.变量没初始化2.输入方式导致TLE 用getchar 导致TLE代码#include<bits/stdc++.h>using namespace std;int vis[200][200];int N, M;char p[200][200];int minn = 400000;int Min = 400000;int l = -1;int t, e;bool ok(int i, int j){ if(i &原创 2020-08-19 22:54:03 · 124 阅读 · 0 评论