摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1548之前用dfs写,,以为可以选择最小的,,当写到那时,就囧了,,不知道怎么处理。。或许真的可以用dfs只是可能要全部搜索才能判断。求路过的大牛指点一二dfs写法!bfs写法:View Code 1 #include<stdio.h> 2 #include<string.h> 3 int map[205]; 4 int vis[205]; 5 int queue[205]; 6 int rear,front; 7 int count; 8 int n; 9 int bfs(int x
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1312题意:就是找从@出发的能经过的'.'的数目。dfs写法:View Code #include<stdio.h>#include<string.h>int col,row;int sx,sy;int sum;int vis[25][25];char map[25][25];void dfs(int x,int y){ if(vis[x-1][y]==0&&map[x-1][y]=='.') { sum++; vis[x-1][y]=1
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1372Knight MovesTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3444Accepted Submission(s): 2153Problem DescriptionA friend of you is doing research on the Traveling Knight Problem (TKP) where you are to fi
阅读全文