![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
搜索
wyl_zheyang
这个作者很懒,什么都没留下…
展开
-
poj 3028 bfs()+克里斯卡尔
/***** 真他娘的恶心,超时了一上午,先是编译器有点问题,然后就一直超时, 原来用了两层for循环,最后优化了一下 改成了一层for()循环AC **/ #include #include #include #include #include using namespace std; char map[55][55]; int dis[55][55]; int father[10010]; i原创 2014-01-10 11:55:09 · 1102 阅读 · 0 评论 -
hdu 1026 反向 bfs() + 前驱保存
做了4个小时,不容易啊,特别是路径保存,特别郁闷 ,最后终于想到了方法, 题意:就是从一点(0,0)——》(n,m),中途会遇见很多的情况:'x'----->陷阱,'.'------>load,'',数字1~9表示怪兽的血量,也就是你要停留几秒,很简单的bfs()+priority_queue,但是,路径保存,不好想,你需要记录当前最犹节点的前驱节点;然后反向bfs()#include #in原创 2013-07-13 19:10:07 · 542 阅读 · 0 评论 -
hdu 1072 Nightmare bfs()
对于这道题目和以往的BFS是不同的 题意:尅你一个map[n][m]; 0: 表示是墙; 1:表示是路 2:表示出发点: 3:表示结束点: 思路: 对与以往的广搜,我们都是要标记的,就是不能走以前走过的路,但是这道题是不同的,就是可以走以前走过的路,但是,这道题,难就难在,路程的标记上 怎么标记呢? 1,再把当前节点加入队列时,判断当前节点的父节点是否满足当前的时间大于1, 2原创 2013-07-15 10:06:30 · 528 阅读 · 0 评论 -
hdu 1015 Safecracker dfs()
此题恶心啊,20分钟的代码,硬是写了2个半小时,最后终于出来了, 题意: 你要得到一个序列 满足 一个关系式; 思路: 枚举排列,然后保存字典序最大的(就是这个恶心啊,,受不鸟,2,个小时啊,代码啊代码) #include #include #include using namespace std; int vis[1001]; char str1[2001]; int原创 2013-07-15 18:25:42 · 464 阅读 · 0 评论 -
NYOJ 523 bfs()此题水
此题水,,只是为了长记性 #include #include #include using namespace std; int map[100][100][100]; int A,B,C,T; int dx[10] = {0,0,0,0,1,-1}; int dy[14] = {0,0,1,-1,0,0}; int dz[14] = {1,-1,0,0,0,0}; typed原创 2013-07-16 10:52:28 · 632 阅读 · 0 评论 -
zoj 1002 dfs()
题意: 就是会给你一些点架设炮台,一架炮台的一行,一列不能再架设炮台,但是有墙除外; 思路: 一,这道题和N皇后差不多,但是不同的是会有一些墙,这些墙变成了问题,为什么呢? 1,他会终止搜索,所以当你发现你的到结果少了,很可能是搜索被中断了 二,那些地方我们能架设炮台那? 1,我们需要从该点出发去判断,判断他的行和列是否有炮台,如果没有则可以放,但是如果遇到强,则该方向不在差,然后枚举原创 2013-07-16 16:57:32 · 572 阅读 · 0 评论 -
NYOJ 21 3个水杯 bfs()
#include #include #include #include using namespace std; int vis[105][105][105]; int v1,v2,v3,E1,E2,E3; typedef struct N1 { int x,y,z,step; } Ac; queue s; void bfs() { Ac yes;原创 2013-07-17 09:53:43 · 446 阅读 · 0 评论 -
Nyoj 24 Point game dfs
/****** 首先说明题意, 1,就是根据 + - * / 和这几个数能否得到一个数 */ #include #include #include #include using namespace std; double a[10]; // 储存数据 int vis[100]; int n,m; char s[10]; // 存储操作符 int fun() // 生成a[]的全排列原创 2013-12-03 13:22:07 · 544 阅读 · 0 评论 -
ZOJ1003
这道题值得记录,,做了一下午,看了书上的代码,, #include bool aTrue,bTrue; int judge(int m,int n,int p) { if(aTrue)return 0; //printf("(m,n,p)==(%d,%d,%d)\n",m,n,p); if(m==1&&n==1)翻译 2013-07-07 18:15:32 · 629 阅读 · 0 评论 -
poj 2965 dfs+保存路径
/***首先叙述题意, 经过最小的次数使得原来的图全部变成‘-’ 暴力枚举 *****/ #include #include using namespace std; char mat[15][15]; int mmin = 100000; struct Node { int x,y; }pre[100], pre2[100]; bool solve(int x,int y) {原创 2014-01-02 20:51:37 · 544 阅读 · 0 评论 -
HDU 1010 Dfs的精华(剪枝)
#include #include #include #include int flog,u,v,d_x,d_y,n,m,k; int dx[5]={0,1,-1,0}; //初始化 4个方向 int dy[5]={1,0,0,-1}; int map[20][20]; void dfs(int x,int y,int step) { if(step >原创 2013-04-23 09:17:25 · 596 阅读 · 0 评论