![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
搜索
文章平均质量分 64
fanxing1
这个作者很懒,什么都没留下…
展开
-
POJ3083 广搜&模拟
晕死,费了我昨天一晚上和今天零零碎碎的一天就做出来这么一道水题,180行代码,搞得我好纠结。本题要求输出从S到E的最短路,沿左边墙和沿右边墙走的步数。求S到E的最短路用广搜,沿墙走用模拟。因本题中模拟部分让我费尽周折,起初思路不够成熟在急着敲代码,不幸夭折N次,而后仔细理清思路后,终于在N+1次AC。以沿左边墙走为例,介绍下模拟的思路:1、首先设选择方向Ldir[4][2]为左上右下.light为左方,right为右方,front为前方2、从起点出发,找到其相邻的墙,左沿墙能走通,由墙所在的方向为左确定前方原创 2011-04-06 20:01:00 · 2163 阅读 · 0 评论 -
POJ1321 深搜
<br />深搜,掌握的不很熟练,递归点老弄不好,加油吧。<br />#include<iostream>using namespace std;char map[8][8];bool rol[8];//标记列是否已放过int n,k;int count;//满足的条件的个数void dfs(int r,int steps){ if(steps==k)//如果已走k步 { count++; return; } if(r>=n) return;//如果越原创 2011-04-08 23:14:00 · 589 阅读 · 0 评论 -
poj3278基本广搜
<br />#include<iostream>#include<algorithm>#include<queue>#define MAX 100001using namespace std;int N,K;bool map[MAX];struct node{ int x; int steps;};int bfs(){ queue<node> que; node pre; pre.x=N; pre.steps=0; map[pre.x]原创 2011-04-09 16:10:00 · 544 阅读 · 0 评论 -
POJ3414广搜&回溯
<br />//bfs+回溯#include<iostream>#include<algorithm>#include<queue>#include<stack>using namespace std;int a,b,c;int res;bool visited[110][110];struct node{ int a,b;//1,2中的水 int steps; int flag;//标记经过的操作 node *pre;//上步状态};st原创 2011-04-13 18:07:00 · 885 阅读 · 0 评论 -
POJ3126Prime Path 基本广搜
<br />#include<iostream>#include<queue>#include<string>#include<stdio.h>#include<ctype.h>#include<stdlib.h>using namespace std;int prime[10000];int visited[10000];int a,b;void Is_Prime()//素数打表{ prime[0]=1;prime[1]=1; for(int i=2;i原创 2011-04-12 15:31:00 · 538 阅读 · 1 评论