bfs/dfs
gzdrn
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
POJ2251 Dungeon Master
简单的搜索,多一个维度 #include #include int l,r,c; int sx,sy,sz; char a[31][31][31]; int book[31][31][31]; int xx[6]={1,-1,0,0,0,0}; int yy[6]={0,0,1,-1,0,0}; int zz[6]={0,0,0,0,1,-1}; struct note { int x,y原创 2016-03-06 23:31:38 · 207 阅读 · 0 评论 -
poj1426 Find The Multiple
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 24082 Accepted: 9981 Special Judge Description Given a positive integer n, write a原创 2016-02-23 22:20:54 · 298 阅读 · 0 评论 -
poj3984迷宫问题
Description 定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, }; 它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短原创 2016-02-24 00:41:50 · 476 阅读 · 0 评论 -
HDU 1241 Oil Deposits(求子块个数)
大意为@相邻的八个位置的@都为同一子块,求子块的个数。 依稀记得学过floodfill的方法求子块个数,但是忘了。。。 于是看了一下题解,发现可以遍历图时DFS实现计数 #include #include char a[101][101]; int book[101][101]; int m,n; int movex[8]={1,1,1,-1,-1,-1,0,0},movey[8]={1,0原创 2016-02-25 01:28:42 · 330 阅读 · 0 评论 -
POJ 3278 Catch That Cow
从可行性出发容易想到BFS,但是每种状态下有3种情况拓展(i-1,i+1,2*i) 数目有点大,因此需要剪枝 1.每个数最大取到k+1才有意义 2.每个数出现一次即可,因此可以用一下hash技术a[]数组 #include int n,k; struct note { int num; int s; }que[1000000]; int a[1000000]; void bfs(voi原创 2016-02-25 19:36:10 · 254 阅读 · 0 评论 -
HDU 2612 Find a way
感觉还是不熟,忙了好久。 #include #include int n,m; char map[205][205]; int a[205][205],b[205][205]; int book[205][205]; int x1,y1,x2,y2; struct note { int x,y; int s; }que[100000]; int next[4][2]={{0,1},{原创 2016-02-25 23:55:15 · 242 阅读 · 0 评论 -
17111 Football team
Description As every one known, a football team has 11 players . Now, there is a big problem in front of the Coach Liu. The final contest is getting closer. Who is the center defense, the full back原创 2016-04-04 23:56:44 · 351 阅读 · 0 评论 -
hdu 1016 Prime Ring Problem
#include #include #include #include using namespace std; int n; int a[21]={0}; int book[21]={0}; int prime[100]; void dfs(int count)//count 为已排好的个数,回溯法 { int i,j; int temp; if(count==n) { for(i原创 2016-07-07 21:40:26 · 263 阅读 · 0 评论
分享