
搜索
木木木木子子子
这个作者很懒,什么都没留下…
展开
-
Tempter of the Bone dfs+剪枝
#include <iostream>#include <cstring>#include <algorithm>using namespace std;int n,m,t,cx,cy;char map[7][7];int visit[7][7];int nexts[4][2]={{0,1},{1,0},{-1,0},{0,-1}};bool ...原创 2018-03-08 20:12:36 · 126 阅读 · 0 评论 -
搜索总结
dfsfor(.....) dfs()枚举每一个状态,一路搜索下去bfsqueue枚举每一个状态并放入队列 得到最快/小的答案A*通过F=g+h 来选定要搜索的状态 +dfsIDA*通过设定阈值 +dfs...原创 2018-04-14 10:05:02 · 158 阅读 · 0 评论 -
poj2286 the rotation game IDA*
转自https://blog.youkuaiyun.com/urecvbnkuhbh_54245df/article/details/5856756 做了点补充迭代加深搜索通常用于求最小次数的情况下/* * POJ2286 The Rotation Game * 解题思路:使用迭代加深的深度搜索算法,这里非常要注意还是剪枝的问题 * 只有较好的针对题目环境的剪枝,才能提高搜索效率 */ ...转载 2018-04-14 09:25:01 · 199 阅读 · 0 评论 -
poj 1753 Flip Game dfs 技巧
dfs 有翻和不翻两种选择,妙#include <iostream>using namespace std;int map[4][4];int next[4][2]= {{0,1},{1,0},{0,-1},{-1,0}};void turn(int x,int y){ int tx,ty; map[x][y]=-map[x][y]; for(int...原创 2018-04-16 19:43:02 · 150 阅读 · 0 评论 -
POJ1020-Anniversary Cake 有技巧的dfs
转自https://blog.youkuaiyun.com/lyy289065406/article/details/6683250对于这种标记,不考虑线段树,而是有技巧的1.首先将小蛋糕的size记录在数组sizeNum[size]++这样做就不用排序什么了,因为数据小在循环时可以用(for(size=10;size>0;size++))来将蛋糕一个个从大到小地放进去2.其次最重要的 用col[i] ...转载 2018-04-10 17:11:47 · 206 阅读 · 0 评论 -
bfs +找路径
转自https://blog.youkuaiyun.com/ly59782/article/details/51019036一个点的接下来点(子节点)有很多,但是他的父节点只有一个(因为有visit标志,所以这个点只会经过一次,而且这一次只会是由他的父节点走来的) so。。记录父节点 lj[New.x][New.y].x=now.x; lj[New.x][New.y].y=now.y;找爸爸void df...转载 2018-04-02 21:26:20 · 238 阅读 · 0 评论 -
双向广搜
题目http://acm.hdu.edu.cn/showproblem.php?pid=1043 八数码转自https://blog.youkuaiyun.com/thudaliangrx/article/details/50659007http://blog.sina.com.cn/s/blog_8627bf080100ticx.html一、主控函数:void solve(){1. 将起始节点放入队列q1,...转载 2018-04-09 21:02:29 · 399 阅读 · 0 评论 -
HDU3533 Escape (BFS)
没有注意到casstle可以抵挡子弹。思路:可能TE?普通的bfs+先updateMap之后判断所要走的点是否有子弹重点是updateMap 伪代码for casstle in vectorif(time%casstle.startTime==0) mapp[ca.x][ca.y]=true;//有子弹 vector.push bulletfor bullet i...原创 2018-04-14 16:39:58 · 170 阅读 · 0 评论 -
hdu1429胜利大逃亡(续) bfs+状态压缩
转自https://blog.youkuaiyun.com/lele_pipi/article/details/46306557原先打算用一个class里面的set 存储钥匙,每次遇上门,就看当前结点的set有没有对应的key每次遇上钥匙就将钥匙插入的这个节点中,同时还要将父节点的钥匙插入这个节点中,显然这样子很花费时间于是考虑状态压缩,问题是怎么压缩?比如怎么用二进制存储钥匙当走到(xx,yy),时首先明确...转载 2018-04-14 15:39:12 · 142 阅读 · 0 评论 -
Codeforces Round #479 (Div. 3)
D利用visit记录访问的顺序#include <iostream>#include <stdio.h>#include <cstring>using namespace std;long long a[101];int visit[101];int num;int count=0,flag=0;void dfs(int k){ vis...原创 2018-05-12 16:01:38 · 122 阅读 · 0 评论