![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ACM_搜素
文章平均质量分 78
thatTime
这个作者很懒,什么都没留下…
展开
-
poj 1979 Red and Black
一开始你站在黑色的格子上, 每次可以上下左右走到相连的黑色格子, 但不能是红色格子, 求能走到的格子数 图的遍历, bfs和dfs都可以, 时间差不多 bfs #include int dx[] = {0, -1, 1, 0, 0}; int dy[] = {0, 0, 0, -1, 1}; char room[25][25], s[25]; bool vis[25][25]; i原创 2013-09-10 20:42:41 · 795 阅读 · 0 评论 -
poj 1562 Oil Deposits
八连快问题, 之前的题解一般都是通过dfs, 我尝试了bfs的写法, 两个时间都差不多 不过dfs代码段一些 dfs #include int dx[] = {0, -1, -1, -1, 0, 0, 1, 1, 1}; int dy[] = {0, -1, 0, 1, -1, 1, -1, 0, 1}; char grid[110][110], s[110]; bool vis[原创 2013-09-11 19:01:18 · 643 阅读 · 0 评论 -
poj 2245 Lotto
从今天开始, 花两个星期做一些搜索题。 #include #include int a[15], b[10], vis[15]; int k, t=0; void dfs(int n) { if(n == 7) { for(int i=1; i<=5; i++) printf("%d ", b[i]); printf("%d\n", b[6]);原创 2013-09-05 21:15:56 · 767 阅读 · 0 评论 -
poj 2251 Dungeon Master
三维空间的广搜, 与二维一样处理,注意细节就可以 #include int dx[] = {0, -1, 1, 0, 0, 0, 0}; int dy[] = {0, 0, 0, -1, 1, 0, 0}; int dz[] = {0, 0, 0, 0, 0, -1, 1}; const int inf = 99999999; char maze[35][35][35], s[35]; i原创 2013-09-14 15:19:38 · 664 阅读 · 0 评论 -
hdu 4152 ZZY’s Dilemma
2011百校联动“菜鸟杯”程序设计公开赛 一道搜索题,应该还是之前搜索的能力还不够,这道题我也做了好长时间,收获还是蛮大的,之前写dfs就完全是套用写全排列的模板,结果放到这题就超时了。 还是枚举所有的可能性,这种枚举方法在标记相同个数时还是按字典序排列的,具体看代码 #include #include int a[25], b[20][25]; bool vis[20], r[20原创 2013-09-25 18:56:55 · 1043 阅读 · 0 评论