随笔分类 -  搜索

摘要:#include <stdio.h>#include <string.h>int x[150][150][150];int w(int a,int b,int c){ if (a<=0||b<=0||c<=0) return 1; if (x[a][b][c]) return x[a][b][c];//用x[a][b][c]进行保留数据,为一个技巧 if (a>20||b>20||c>20) return x[a][b][c]=w(20,20,20); if (a<b&&b<c) return x[a][b 阅读全文
posted @ 2013-04-23 19:08 一线添 阅读(156) 评论(0) 推荐(0)
摘要:特点:1:此题不要标记,因为走过的点可能还要走,进入方向不一样(如果点的特征会发生变化,那么就不能标记)2:由于此题不能拉,所以在箱子移动的时候,必须要判断是否有某点,从该点人可以把箱子移到目标位置(DFS)#include <iostream>#include <cstdio>#include <queue>#include <string.h>using namespace std;int n,m,sx,sy,ex,ey,ptx,pty,s[15][15],vis[15][15][15][15],flag[15][15];struct nod 阅读全文
posted @ 2013-04-16 18:03 一线添 阅读(113) 评论(0) 推荐(0)
摘要:#include <iostream>#include <cstdio>#include <queue>using namespace std;int dir[4][2]={0,1,0,-1,1,0,-1,0};struct node{ int x; int y; int z; int time;};int sx,sy,sz,ex,ey,ez,N,M,T,mark[3][100][100];char s[3][100][100];void BFS(){ queue<node>Q; node p,q; p.x=sx; p.y=sy; p.z=... 阅读全文
posted @ 2013-04-15 16:55 一线添 阅读(115) 评论(0) 推荐(0)
摘要:特点:1:走过的路不能标记,因为等会可能还会走(当需要增加距离爆炸时间的时候)2: 在没有对顶点做标记的情况下,需要通过将访问过了的4标记为0,以减小搜索范围, 这样才能跳出while(!Q.empty())循环3: 队列里的时间不是从大到小的,因为4位置会改变时间,比如6,4,2,在遇到4时 会变成6,4,2,6,(见标记2)#include <iostream>#include <queue>#include <cstdio>using namespace std;int m,n,s[10][10],sx,ex,sy,ey;struct node{ in 阅读全文
posted @ 2013-04-15 10:24 一线添 阅读(143) 评论(0) 推荐(0)