摘要: 这题真实水的无与伦比的快乐,当然中间debug稍微浪费了点时间。很简单的DFS #include <iostream> #include <algorithm> #include <queue> #include <string> #include <vector> #include <cstdio 阅读全文
posted @ 2021-04-19 22:24 IdiotNe 阅读(35) 评论(0) 推荐(0) 编辑
摘要: 开始规划思路,一开始想错了,直接想着用BFS解决,对于这两者的理解也因为这更深刻了些。 BFS寻求源点到目的地的最短距离,而DFS才适合于这种树全搜索情况(当然更符合DFS的应用应该是算法导论上的拓扑排序以及相关连通分量) 这道题思路很简单,但是调试过程太曲折了,期间很多细节都没有重视,比如在搜索的 阅读全文
posted @ 2021-04-19 22:03 IdiotNe 阅读(45) 评论(0) 推荐(0) 编辑
摘要: 这么多天其实被BFS DFS各种神仙延申搞得人欲罢不能 来到水题轻松切一下 #include <iostream> #include <algorithm> #include <queue> #include <string> #include <vector> #include <cstdio> 阅读全文
posted @ 2021-04-19 19:42 IdiotNe 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 贪吃蛇问题,因为图的复杂性,为了空间效率,这时候就要考虑利用状态压缩来处理。 算法倒是没有多复杂,但是非常考验码力,耐心,中间很多细节小错误(循环,判断顺序) 开始状态压缩想的麻烦了,经过思考,将状态压缩集中到贪吃蛇形状,以及利用贪吃蛇的连贯性,就可以大大节省效率 #include <iostrea 阅读全文
posted @ 2021-04-19 17:14 IdiotNe 阅读(36) 评论(0) 推荐(0) 编辑