
深度优先搜索
文章平均质量分 65
wsxsd94
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Hdu1181 - 变形课 - 深度优先搜索
#include #include char se[100]; int change[30][30]; int mark[30][30]; int dfs(int n) { if(n==12) { return 1; } for(int i=0;i<26;i++) { if(change[n][i]==1&&mark[n][i]==0) { mark[n][i]=1;原创 2014-07-19 11:38:29 · 505 阅读 · 0 评论 -
POJ1562 - Oil Deposits - 深度优先搜索
#include char map[105][105]; int n,m; int to[8][2]={{-1,0},{1,0},{0,-1},{0,1},{-1,1},{-1,-1},{1,1},{1,-1}}; void dfs(int x,int y) { int nx,ny,i; map[x][y]='*'; for(i=0;i<8;i++) { nx=x+to[i][0];原创 2014-07-16 08:49:17 · 416 阅读 · 0 评论 -
POJ2488 - A Knight's Journey - 深度优先搜索
#include #include int ux[30]/*所走过路数的列坐标*/,uy[30]/*所走过路数的行坐标*/,mark[30][30]/*标记走过的点*/,m/*棋盘行数*/,n/*棋盘列数*/,flag/*控制输出impossible变量*/; int to[8][2]={{-1,-2},{1,-2},{-2,-1},{2,-1},{-2,1},{2,1},{-1,2},{1,2}原创 2014-07-12 14:22:30 · 453 阅读 · 0 评论 -
POJ3083 - Children of the Candy Corn - 深度优先搜索+广度优先搜索
#include #include char map[45][45]; int mark[45][45]; int visit[45][45]; int towards;//0向上,1向左,2向下,3向右 int left,right; struct po { int x,y,id; }ed,queue[2000],st,item; void dfsl(int x,int y,int to) {原创 2014-07-16 08:51:15 · 434 阅读 · 0 评论 -
URAL1005 - Stone Pile - 深度优先搜索
这道题正解应该是01背包,但是数据比较水,20个数据,所以深搜暴力解决了原创 2014-08-07 17:31:13 · 728 阅读 · 0 评论 -
Hdu1010 - Tempter of the Bone - 深度优先搜索
#include #include int m,n,t; char map[10][10]; bool mark[10][10]; int tx,ty,flag; int div[4][2]={{1,0},{-1,0},{0,-1},{0,1}}; int fabs(int n) { return n>0?n:-n; } void dfs(int sx,int sy,int dep) {原创 2014-07-19 11:35:51 · 431 阅读 · 0 评论 -
POJ3009 - Curling 2.0 - 深度优先搜索
#include #include int map[25][25]/*地图*/; int m/*行坐标*/,n/*列坐标*/,sx/*起点列坐标*/,sy/*起点行坐标*/,ex/*终点列坐标*/,ey/*终点行坐标*/,best/*最少步数*/; int to[4][2]={{1,0},{-1,0},{0,1},{0,-1}};//四个方向移动 void dfs(int x/*当前列坐标*/,i原创 2014-07-13 10:31:57 · 458 阅读 · 0 评论