搜索
DFS+BFS
井中月_笼中雀
acmer
展开
-
POJ - 3126 -Prime Path 搜索 BFS
The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices. — It is a matter of security to change such things every now and then, to keep原创 2020-10-10 22:15:42 · 124 阅读 · 0 评论 -
NC14608-after与迷宫(双BFS)
after与迷宫-NC14608(两次bfs) after的算法书的遗落在一个叫做AIJ的迷宫中了,这个迷宫有N*M个房间,迷宫的入口为(1,1),算法书遗落在(r,c)。迷宫中的房间有四种状态:空房间、无法进入的房间、有墨菲斯托存在的房间和有莉莉丝存在的房间。墨菲斯托会否定一切,而莉莉丝会诱惑人做一种叫做YK的活动。after是一个意志薄弱的人,他遇到了墨菲斯托和莉莉丝之后,便会变成眼神空洞的超级YK机器人。after每步可以从他当前的房间走至上下左右四个房间的其中一个房间。after害怕变成超级YK机器原创 2020-10-09 22:24:28 · 261 阅读 · 0 评论 -
POJ - 2531 Network Saboteur 最大割 DFS
自己一开始没咋看明白,很多知识点都不知道。 转载两份代码。 第一份: 出处:http://exp-blog.com 大佬思想: 题目大意: 把一个完全图分成两部分,使得连接这两部分边的权和最大。 解题思路: 图论的无向完全图的最大割问题 (做网络最大流的时候同学们应该看过最小割,所以别问我什么是最大割了。。。不懂的百度去。。。) 可以用 随机化算法 Random Algorithm 去做 一开始我没读懂题,以为是求最大权。。。傻呼呼的用最了最小生成树的算法去做= = 一直RERERE。。。还以为是数组开得不原创 2020-10-08 23:35:18 · 188 阅读 · 0 评论 -
HDU1175(dfs+剪枝)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1175 dfs: 定义函数时注意设计参数 本题:dfs(x,y,dic,turns) x,y为当前搜索起点 dic为当前前进方向 turns为当前转弯数 注意初始化及边界情况 注意搜索终止条件 思路: dfs搜索 剪枝:第二次转弯后,判断与目标是否在同一直线上 #include"iostream" #include"cstdio" #include"stdlib.h" #include"cmath" #inclu原创 2020-10-05 21:30:16 · 101 阅读 · 0 评论 -
POJ 3279 搜索
Time limit 2000 ms Memory limit 65536 kB Description Farmer John knows that an intellectually satisfied cow is a happy cow who will give more milk. He has arranged a brainy activity for cows in which they manipulate an M × N grid (1 ≤ M ≤ 15; 1 ≤ N ≤ 15) o转载 2020-09-26 11:29:31 · 119 阅读 · 0 评论 -
POJ1321 简单搜索
题目: 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。 Input 输入含有多组测试数据。 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <= 8 , k <= n 当为-1 -1时表示输入结束。 随后的n行描述了棋盘的形状:每行有n个字符,其中 # 表示棋盘区域, . 表原创 2020-09-19 20:25:03 · 81 阅读 · 0 评论 -
HDU-1010 奇偶性剪枝+dfs
Problem Description The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He realized that the bone was a trap, and he tried desperately原创 2020-09-17 20:19:22 · 96 阅读 · 0 评论