2013年7月29日

图的深搜和广搜模板(多校联合第一场Park Visit)

摘要: #include #include #include #include #include using namespace std;int ans,end;vector graph[100001];int visited[100001] = {0};typedef struct{ int v,n;}Node; void dfs(int v){ vector::iterator it; visited[v] = 1; //printf("%5d", v); for (it = graph[v].begin(); it != graph[v].end(); ++it) ... 阅读全文

posted @ 2013-07-29 15:14 Gddxz 阅读(172) 评论(0) 推荐(0) 编辑

深度优先模板(POJ2488)

摘要: #include #include int dir[8][2]={{-2,-1},{-2,1},{-1,-2},{-1,2},{1,-2},{1,2},{2,-1},{2,1}};int flag[100][100],cnt,m,n;struct node{ char letter; int num;}arr[1000];void dfs(int a,int b,int cur){ /*赋值*/ arr[cur].letter='A'+a-1; arr[cur].num=b; flag[a][b]=1; /*判断结束条件*/ if(cur==m*n) { cnt=cur; re 阅读全文

posted @ 2013-07-29 11:34 Gddxz 阅读(119) 评论(0) 推荐(0) 编辑

导航