2012年8月19日
摘要: 优先队列+BFS的经典题型。CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>#include<queue>usingnamespacestd;#defineSIZE201#defineINF0x0fffffffconstintmove[4][2]={{1,0},{-1,0},{0,-1},{0,1}};charmaze[SIZE][SIZE];intTime[SIZE][SIZE];intN,M;intbx,by,ex,ey;structnode{friendbooloperat 阅读全文
posted @ 2012-08-19 18:54 有间博客 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 简单搜索。DFS求图有几个连通分量。CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>#include<math.h>usingnamespacestd;constintSIZE=110;constintmove[8][2]={{-1,-1},{-1,0},{-1,1},{0,1},{0,-1},{1,1},{1,0},{1,-1}};charmaze[SIZE][SIZE];intN,M;intcheck(intr,intc){if(maze[r][c]!='*' 阅读全文
posted @ 2012-08-19 15:58 有间博客 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 简单搜索题,由于很久没写搜索题的缘故,我自己的模板出现了小问题。注意:1、如果maze[q.x][q.y] == 4的话可能会出现死循环,所以要走过之后直接标记为0。CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>#include<queue>usingnamespacestd;constintSIZE=110;intmaze[SIZE][SIZE];constintmove[4][2]={{1,0},{-1,0},{0,-1},{0,1}};intflag[SIZE][SIZE 阅读全文
posted @ 2012-08-19 12:02 有间博客 阅读(199) 评论(0) 推荐(0) 编辑