深度搜索模板

#include <iostream>
#include <cstdio>
using namespace std;
void dfs(/*起始坐标*/){
 if(/*找到出口*/){
  //操作
  return ;
 }
 for(/*循环遍历所有方向*/){
  if(/*新的坐标不符合条件*/)
   continue;
  //操作
  dfs(/*继续向下搜索新的坐标*/);
  //回溯
 }
}
int main(){
 //读入数据
 dfs(/*起点坐标*/);
 
 return 0;
}

posted @ 2019-10-02 21:43  晴屿  阅读(231)  评论(0编辑  收藏  举报