个人心得:一开始用DFS弄了半天一直输出不了结果,后面发现并没有进行判断:好不容易能够得出答案,结果超时了,才发现原来要用BFS: 对于DFS: 从一个点开始模拟能走的所有步骤,注意边界条件,走到不能走时返回上一步继续循环:耗时比较大,主要要注意当前的动作 格式的话 void dfs(int step) { 判断边界 尝试每一种可能 { 注意标记: 继续下一步: } 返回 } BFS广度搜索,能够走得位置都走,将能到达的位置进入队列,当一个位置的所有动作完成时出队列,注意标志不改变,当队列为空时…