摘要: http://poj.org/problem?id=2488DFS+回溯,其实不用从所有节点开始搜索,因为要求输出的是字典序,所以只从A1开始搜索,能一次搜到便是存在,否则不存在。写完代码才意识到。另外注意字典序时,方向数组要写对。 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <stack> 5 using namespace std; 6 int c; 7 int n,p,q; 8 int start_x,start_y; 9 int t 阅读全文
posted @ 2013-02-14 16:04 linyvxiang 阅读(355) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2243BFS模板题 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <queue> 5 using namespace std; 6 char pos_start[3],pos_end[3]; 7 bool visited[20][20]={false}; 8 int dis[20][20]={0}; 9 typedef struct Node {10 int x,y;11 }Node;12 阅读全文
posted @ 2013-02-14 10:15 linyvxiang 阅读(161) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1979DFS模板题. 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 int W,H; 5 char map[22][22]; 6 int count=0; 7 bool check(int x,int y) 8 { 9 if(!(1<=x&&x<=H&&1<=y&&y<=W)) return false;10 return true;11 }12 阅读全文
posted @ 2013-02-14 09:23 linyvxiang 阅读(262) 评论(0) 推荐(0) 编辑