
bfs
躺平平的弱鸡
IT界资深菜鸟。。
展开
-
NYOJ92图像有用区域
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=92这道题略坑,用深搜肯定就RE了,后来搜下了题解,用的广搜,还要进行加边处理。。。。代码:#include #include #include #include #include using namespace std;typedef struct原创 2016-04-09 16:35:46 · 478 阅读 · 0 评论 -
NYOJ483噩梦(优先队列 + 无标记)
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=483本题重点是访问完一次4之后要置成1或者0,防止多次重置。 因为这个我错了好多次。代码:#include #include #include #include #include using namespace std原创 2016-09-18 20:02:32 · 319 阅读 · 0 评论 -
NYOJ21三个水杯
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=21思路:一共分12种情况 举个例子 A -> C倒水的时候,可能把C装满,可能不满。这就是两种情况 所有的情况 A -> B (B可能满,可能不满) A -> C B原创 2016-09-03 15:07:33 · 301 阅读 · 0 评论 -
NYOJ592spiral grid
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=592 思路:(1)建图 (2)打素数表 (3)BFS搜索代码:#include #include #include int s[110][100];int v[110][100];int t_cnt = 1;bool flag ;typ原创 2016-09-02 23:38:30 · 285 阅读 · 0 评论 -
NYOJ523亡命逃窜
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=523这个题不能用STL的优先队列了,要不会超时。还是BFS搜索最优解.这个城堡由A层,每层的大小是B * C的,入口在(0,0,0),出口在(A - 1,B - 1,C - 1)处,在给定时间内出去就好思路:先搜索本层,在搜索邻接的两层。原创 2016-09-02 19:48:59 · 404 阅读 · 0 评论 -
NYOJ3533D dungeon
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=353BFS+优先队列 代码:#include #include #include using namespace std;int l,r,c;int stx,sty,stz;int enx,eny,enz;bool flag;stru原创 2016-09-02 19:04:51 · 637 阅读 · 0 评论 -
hdu1071Nightmare(BFS+优先队列)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1072这个题用普通的队列也可以,关键的地方是 对于炸弹重置装置只能访问一次,虽然题中允许访问多次。我的代码:#include #include #include using namespace std;int n,m;int a[50][50];int原创 2016-05-09 22:12:15 · 764 阅读 · 0 评论 -
hdu1195Open the Lock
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1195搜索就三种规则, 一个是+1 一个是-1 还有一个是交换,用bfs搜索就行了,参照大神的思路。。。代码:#include #include #include using namespace std;int a[5];int b[5];st原创 2016-05-06 18:12:48 · 632 阅读 · 0 评论 -
hdu1181变形课
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1181广搜就好了。。代码:#include #include #include using namespace std;char s[1005];int a[30][30];int v[30];int flag ;void bfs(){原创 2016-05-06 17:09:52 · 437 阅读 · 0 评论 -
hdu1180诡异的楼梯(bfs)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1180这个题真的是坑啊。。 等楼梯的时候要看看对面是否已经访问过了,如果访问过了,就没有必要过楼梯了。。。。 这点很重要。。。。代码:#include #include #include using namespace std;char s[30][30]原创 2016-05-05 19:36:19 · 343 阅读 · 0 评论 -
hdu1026Ignatius and the Princess I(BFS + 优先队列)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1026模板题。代码:#include #include #include using namespace std;int n,m;char s[105][105];int v[105][105];int dx[] = {-1,0,1,0};int原创 2016-05-13 18:13:50 · 276 阅读 · 0 评论 -
hdu1495非常可乐(BFS)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1495第一次做这种搜索,看了别人了博客,说是6种状态,没想到BFS还可以这么用。^_^代码:#include #include #include using namespace std;const int maxn = 105;int a,b,c;st原创 2016-05-13 16:58:15 · 283 阅读 · 0 评论 -
NYOJ1100WAJUEJI which home strong!
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=1100BFS + 优先队列! 自定义优先级!!!!!代码:#include #include #include using namespace std;typedef struct Node{ int x,y; char c;原创 2016-04-16 19:57:29 · 556 阅读 · 0 评论 -
hdu1728逃离迷宫(BFS最优解)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1728这道题是利用了BFS中的DFS思想,从上下左右4个点扩展到了4个方向。 这是本题的重点。代码:#include #include #include using namespace std;char s[105][105];int n,m;int k,x1原创 2016-05-11 20:32:56 · 810 阅读 · 2 评论 -
hdu1372Knight Moves
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1372一个可以走8个方向。BFS求最短路代码:#include #include #include using namespace std;int v[10][10];int stx,sty,enx,eny;struct node{ int原创 2016-05-11 18:14:21 · 368 阅读 · 0 评论 -
NYOJ284坦克大战
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=284BFS求最短路,这个题走到‘B’点是要花费2个时间,'E‘是1个时间,所以要用一个优先队列,优先级就是花费小的先出队,其余的就是模板了。代码:#include #include #include using namespace std;#原创 2016-04-10 21:08:48 · 480 阅读 · 0 评论 -
hdu1104Remainder(BFS)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1104BFS,没什么说的。代码:#include #include #include #include #include using namespace std;const int maxn = 1e6;int n,k,m;int key;int原创 2016-05-09 20:26:19 · 1060 阅读 · 0 评论