果枫-国峰

随笔分类 -  DFS深度优先搜索

hdu 1426
摘要:题意:中文题,此处省。ac代码:View Code #include<iostream>using namespace std;int map[12][12];int k; int foat;struct tree{ int i; int j;}node[90];int check(struct tree n,int p){ int i,j; int x,y; for(i=1;i<=9;i++)//判断行与列是否已经存在p { if(map[n.i][i]==p||map[i][n.j]==p) return 0; ... 阅读全文

posted @ 2012-09-11 21:05 果枫-国峰 阅读(130) 评论(0) 推荐(0)

hdu 1258
摘要:题意:中文题,省。ac代码:View Code #include<iostream>#include<string.h>#include<algorithm>using namespace std;int a[15];int use[15];int foat;//判断是否要输出“NONE”int t,n;int k;//use[]数组中使用bool cmp(int a,int b){ return a>b;}void dfs(int s,int step,int k){ if(t==s) { foat=1; for(int i=0;i<k-1;i 阅读全文

posted @ 2012-09-11 21:03 果枫-国峰 阅读(136) 评论(0) 推荐(0)

hdu 杭电 1016 Prime Ring Problem
摘要:ac代码:View Code #include<iostream>using namespace std;int map[61];int use[21];int ss[22];int n;void dfs(int i){ if(i==n&&map[ss[i-1]+1]==0) { for(int l=0;l<n-1;l++) cout<<ss[l]<<" "; cout<<ss[n-1]<<endl; } else { for(int j=2;j<=n;j++) { ... 阅读全文

posted @ 2012-09-01 09:30 果枫-国峰 阅读(154) 评论(0) 推荐(0)

hdu 杭电 1045 Fire Net
摘要:题意:地图中最多能放多少炮台。解法:深搜。ac代码:View Code #include<iostream>using namespace std;char map[8][8];int sum,maxi,n;bool check(int x,int y){ if(map[x][y]=='X')return 0; int i; for(i=x-1;i>=0;i--) { if(map[i][y]=='X')break; if(map[i][y]=='0')return 0; } for(i=y-1;i>=0;i--) { . 阅读全文

posted @ 2012-09-01 09:25 果枫-国峰 阅读(226) 评论(0) 推荐(0)

导航