随笔分类 - Search Algorithm
Basic but important!
摘要:原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1010分析:dfs+奇偶剪枝。Tempter of the Bone 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 char s[10][10]; 7 bool visit[10][10],flag; 8 int dx[4]={0,0,1,-1}; 9 int dy[4]={-1,1,0,0};10 int n,m,t,di,dj;11 void dfs(int time,int i,int j)12 {13
阅读全文
摘要:原题链接:http://poj.org/problem?id=2488分析:如果存在合法路径,那么一定可以将路径的起始点定为(A,1),从该点按字典序DFS,如果找到一条路径,那么这条路即为所求。 1 #include 2 #include 3 #include 4 #include 5 #define maxn 27 6 using namespace std; 7 int dirx[8]={-2,-2,-1,-1,1,1,2,2}; 8 int diry[8]={-1,1,-2,2,-2,2,-1,1}; 9 char path[maxn0&&ny>0&&am
阅读全文

浙公网安备 33010602011771号