摘要: 深搜,亮点在那个剪枝,flag代表是否搜索数组从开始到当前一直等于原始数组同位置的数,如果是真,就从原始数组的当前位置的书开始搜,否则就从0开始搜。见代码。#include #include using namespace std;int n,m,beg,origin[2003];int mp[103][103];bool vis[103][103];int cnt;int stk[2010];bool check(){ int i; for(i=0;iorigin[i]) return true; } return false;}void dfs(... 阅读全文
posted @ 2013-11-09 15:30 Al J 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 杭州现场赛的题。BFS+DFS#include #include#include#define inf 9999999using namespace std;char mp[105][105];int sq[5][5];int step[4][2]={{0,1},{1,0},{0,-1},{-1,0}};struct pos{ int x,y;};int n,m,prn,x,y,tmp,ans,cnt;bool viss[5];int bfs(pos bg,pos ed){ int i; pos que[20000]; int front=0,rear=1; bo... 阅读全文
posted @ 2013-11-09 15:24 Al J 阅读(213) 评论(0) 推荐(0) 编辑