
BFS、DFS
huxinjianzs
这个作者很懒,什么都没留下…
展开
-
HDU - 1044 Collect More Jewels
题目地址:HDU-1044HDU ACM 1044 Collect More Jewels BFS+DFS用BFS转化为DFS常见情况求解#include #include #include #include using namespace std;int map[60][60];int jewel[60];int w,h,l,m;int valu转载 2017-02-23 20:35:46 · 272 阅读 · 0 评论 -
A very hard Aoshu problem HDU-4403
原题:HDU-4403先用递推列出所有数字组合,然后再用DFS尝试匹配各种组合#include #include #include using namespace std;char s[20];long long a[20][20];int L;int sum;void dfs(int start,int end,long long v,long long原创 2017-02-23 22:18:59 · 215 阅读 · 0 评论 -
连连看 HDU-1175
原题:HDU-1175这个题目不难,主要是要剪枝,不然就会超时当转折满了两次之后,判断一下只能往前走的情况下是否能到达目标点,可以的话就直接成功return 否则就return回去继续递归#include #include #include using namespace std;int n,m;int s[1050][1050];int原创 2017-02-24 15:19:39 · 271 阅读 · 0 评论 -
Sudoku Killer HDU-1426
题目地址:HDU-1426直接用DFS应该会超时,然后我做了一个预处理,先把他们能选择数字先找出来,然后再DFS#include #include #include using namespace std;char map[12][12];int yes;struct node { int x,y; int v[10];} N[100];原创 2017-02-24 22:31:58 · 224 阅读 · 0 评论 -
逃离迷宫 HDU-1728 BFS深度搜索
题目:HDU-1728参考:HDU1728 BFS#include #include #include #include using namespace std;char map[110][110];int v[110][110];int n,m,k,yes;int X[]= {0,0,-1,1};int Y[]= {-1,1,0,0};struct转载 2017-02-25 11:38:19 · 236 阅读 · 0 评论 -
飞越原野 DFS寻找最优路径
原题:飞越原野很简单的一道DFS题,注意看好题意就行了#include #include #include using namespace std;char map[110][110];int v[110][110];int n,m,d;int X[]= {0,0,1,-1};int Y[]= {1,-1,0,0};int yes,sum;int ju原创 2017-03-12 10:05:25 · 829 阅读 · 0 评论 -
POJ-3278 catch that cow 广度优先搜索
以牛的位置为起始点向前搜索,注意状态更新就好了不要问我为什么是从后往前搜...我也不知道,我第一遍从前往后搜的wa了 然后换从后往前搜就AC了...#include #include #include #include #include #include #include using namespace std;int dis[100005];int b原创 2017-07-31 15:20:39 · 236 阅读 · 0 评论