
广度优先搜索
文章平均质量分 77
wsxsd94
这个作者很懒,什么都没留下…
展开
-
Hdu1240 - Asteroids! - 广度优先搜索
#include#includeint n;char a[10];char map[105][105][105];int mark[105][105][105];int to[6][3]={{1,0,0},{0,1,0},{0,0,1},{-1,0,0},{0,-1,0},{0,0,-1}};struct { int x,y,z,id;}queue[1000005],s,e,n原创 2014-07-19 15:22:51 · 474 阅读 · 0 评论 -
URAL1008 - Image Encoding - 广度优先搜索
这道题不太理解了,我总共写了3种代码,虽然大体思路一样,但是结果不一样,最后一种终于能在VC原创 2014-08-09 10:37:10 · 624 阅读 · 0 评论 -
Hdu1242 - Rescue - 广度优先搜索
#include#includeint m,n;char map[210][210];int mark[210][210][2];int to[4][2]={{0,1},{1,0},{0,-1},{-1,0}};struct point{ int x,y,step; int bury;//0有坑,1没坑}queue[1000010],st,ed,now;void bfs()原创 2014-07-19 11:37:08 · 466 阅读 · 0 评论 -
Hdu1072 - Nightmare - 广度优先搜索
#includeint m,n;int map[10][10];int to[4][2]={{1,0},{-1,0},{0,1},{0,-1}};int mark[10][10];struct{ int x,y,time,id;}queue[100],now,next,s,e;int bfs(){ int fr,ed,i,j; fr=ed=0; s.time=0; s.原创 2014-07-19 12:45:06 · 461 阅读 · 0 评论 -
POJ3278 - Catch That Cow - 广度优先搜索
#include#includeint to[3]={-1,1,2};int mark[200005];struct{ int x,id;}queue[200005],st,ed,now,next;int bfs(){ int fro,end; fro=end=0; st.id=0; queue[end++]=st; mark[st.x]=1; while(fro<e原创 2014-07-16 08:44:41 · 433 阅读 · 0 评论 -
Hdu1312 - Red and Black - 广度优先搜索
#include#includeint m,n;char map[25][25];int mark[25][25];int to[4][2]={{1,0},{-1,0},{0,1},{0,-1}};struct { int x,y;}queue[405],st,now,next;int bfs(){ int num=1; memset(mark,0,sizeof(mark原创 2014-07-19 12:15:32 · 477 阅读 · 0 评论 -
Hdu1175 - 连连看 - 广度优先搜索
#include#includeint to[4][2]={{1,0},{-1,0},{0,1},{0,-1}};int mark[1005][1005];int map[1005][1005];int m;int n;int t;struct{ int times; int x,y;}queue[1000005],st,ed,now,next;void bfs(){原创 2014-07-19 11:40:04 · 599 阅读 · 0 评论 -
POJ3414 - Pots - 广度优先搜索
#include#includeint a,b,c;int mark[1000][1000];int op[1005];struct{ int v1,v2,caozuo,id,p;}queue[100005],st,now,next,item;int bfs(){ memset(mark,0,sizeof(mark)); int fro,end; fro=end=0;原创 2014-07-16 10:16:13 · 448 阅读 · 0 评论 -
POJ3083 - Children of the Candy Corn - 深度优先搜索+广度优先搜索
#include#includechar map[45][45];int mark[45][45];int visit[45][45];int towards;//0向上,1向左,2向下,3向右int left,right;struct po{ int x,y,id;}ed,queue[2000],st,item;void dfsl(int x,int y,int to){原创 2014-07-16 08:51:15 · 422 阅读 · 0 评论 -
POJ1915 - Knight Moves - 广度优先搜索
#include#includeint n;int mark[305][305];int to[8][2]={{1,2},{-1,2},{1,-2},{-1,-2},{2,1},{2,-1},{-2,1},{-2,-1}};struct{ int x,y,id;}st,ed,queue[100000],now,next;int bfs(){ memset(mark,0,siz原创 2014-07-16 09:11:56 · 420 阅读 · 0 评论 -
POJ2251 - Dungeon Master - 广度优先搜索
#include#includechar map[35][35][35];int mark[35][35][35];int to[7][4]={{0,0,1},{0,0,-1},{1,0,0},{-1,0,0},{0,1,0},{0,-1,0}};int a,b,c;struct{ int x,y,z,id;}queue[27005],st,ed,now,next;int bf原创 2014-07-16 09:37:43 · 426 阅读 · 0 评论 -
Hdu1180 - 诡异的楼梯 - 广度优先搜索
#include#includeint m,n;char map[25][25],map1[25][25];int mark[25][25];int to[4][2]={{1,0},{-1,0},{0,1},{0,-1}};struct{ int x,y,id,stop/*0为不停,1为停*/;}queue[1000],s,e,now,next;int bfs(){ mem原创 2014-07-19 14:39:08 · 421 阅读 · 0 评论 -
Zstu2428 - How to be An ACMan - 广度优先搜索
鉴于没多少人看过这道题,给传送门:原创 2014-08-10 10:00:21 · 512 阅读 · 0 评论