![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
DFS 算法
文章平均质量分 54
DFS 算法的题目
上官凝轩2017
这个作者很懒,什么都没留下…
展开
-
洛谷 P1219 (DFS + 回溯)
import java.io.*;import java.util.*;/****思路:DFS加回溯* 技巧就是对于斜对角线上面是否有结点的判别,* 算一下就知道,左下到右上斜对角线i+j=固定值,左上到右下i-j+n=固定值* @author m*/public class P1219 { static int row[] = new int [50];//行 static int col[] = new int [50];//列 static int ...原创 2021-06-27 19:27:51 · 175 阅读 · 0 评论 -
DFS的模板
void dfs(int x)//关于传入参数问题,根据题意而定,看在题目运行的过程中,哪些是在变得{ if(满足输出条件) { 输出解; return ; } if(目前已经没有必要进行下去的条件){ return ; }//剪枝操作 //如果传入的条件,还需要继续搜下去,分析每一种情况后面跟哪些情况,然后循环,每个情况(注意前提:得符合题意)都深搜一下 for(int i=1;i<=每种情况...转载 2021-06-27 20:29:25 · 52 阅读 · 0 评论 -
洛谷 P1605 迷宫 (DFS)
import java.io.*;import java.util.*;public class P1605 { static int sx,sy;//起点 static int ex,ey;//终点 static int nodes[][] = new int[100][100]; static int N,M,T; static int res; public static void main(String[] args) throws Except...原创 2021-06-27 20:31:14 · 83 阅读 · 0 评论