深度搜索模板

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

猜你喜欢

转载自www.cnblogs.com/QingyuYYYYY/p/11618573.html
今日推荐