随笔分类 -  DFS

摘要:题目链接:https://www.luogu.com.cn/problem/P7074 一、dfs(25分)没有任何优化,时间复杂度约(O(3^(n*m))) 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, m; 4 int a[1 阅读全文
posted @ 2020-11-19 15:20 TFLSNOI 阅读(534) 评论(0) 推荐(0) 编辑
摘要:http://ybt.ssoier.cn:8088/problem_show.php?pid=1219 1 #include<cstdio> 2 #include<cstring> 3 using namespace std; 4 int t;//表示输入t组数据 5 int n, m;//棋盘大小 阅读全文
posted @ 2020-10-04 16:08 TFLSNOI 阅读(1065) 评论(0) 推荐(0) 编辑
摘要:http://ybt.ssoier.cn:8088/problem_show.php?pid=1250 此题目难点: 1.利用二进制的与运算判断与隔壁房间是否有墙,从而求出下一步的方向 2.与运算的优先性 3.代码的调试 1 #include<bits/stdc++.h> 2 using names 阅读全文
posted @ 2020-09-30 21:15 TFLSNOI 阅读(576) 评论(0) 推荐(0) 编辑
摘要:http://ybt.ssoier.cn:8088/problem_show.php?pid=1249&teacher=2 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, m; 4 char mp[120][120]; 5 int 阅读全文
posted @ 2020-09-30 15:52 TFLSNOI 阅读(461) 评论(0) 推荐(0) 编辑
摘要:http://ybt.ssoier.cn:8088/problem_show.php?pid=1329 方法一:DFS 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, m; 4 char c; 5 char a[1000][1000 阅读全文
posted @ 2020-09-26 22:55 TFLSNOI 阅读(708) 评论(0) 推荐(0) 编辑
摘要:题目链接http://ybt.ssoier.cn:8088/problem_show.php?pid=1216 方法一:DFS 1 #include<bits/stdc++.h> 2 using namespace std; 3 int w, h; //h代表行数, w代表列数 4 int sx, 阅读全文
posted @ 2020-09-22 11:09 TFLSNOI 阅读(1217) 评论(0) 推荐(0) 编辑
摘要:题目链接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1217 1 #include <bits/stdc++.h> 2 const int max_n=10; 3 using namespace std; 4 bool vis[max_n];//记 阅读全文
posted @ 2020-09-21 23:58 TFLSNOI 阅读(614) 评论(0) 推荐(0) 编辑
摘要:“回溯法”也称“试探法”。它是从问题的某一状态出发,不断“试探”着往前走一步,当一条路走到“尽头”,不能再前进(拓展出新状态)的时候,再倒回一步或者若干步,从另一种可能的状态出发,继续搜索,直到所有的“路径(状态)”都一一试探过。这种不断前进、不断回溯,寻找解的方法,称为“回溯法”。 他的基本思想是 阅读全文
posted @ 2020-09-18 10:31 TFLSNOI 阅读(3174) 评论(0) 推荐(0) 编辑
摘要:题目链接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1318 方法一:DFS 1 #include<bits/stdc++.h> 2 using namespace std; 3 int ans[21]; //用于存放答案 4 int n, tot 阅读全文
posted @ 2020-09-18 09:00 TFLSNOI 阅读(816) 评论(0) 推荐(0) 编辑
摘要:一、DFS实现N皇后 1 #include<bits/stdc++.h> 2 using namespace std; 3 int ans[10];//用于存放答案 4 int tot;//方案数 5 const int n=8;//N皇后问题 6 bool check(int c, int r){ 阅读全文
posted @ 2020-09-17 23:32 TFLSNOI 阅读(241) 评论(0) 推荐(0) 编辑
摘要:https://www.luogu.com.cn/problem/P4913 #include<bits/stdc++.h> using namespace std; struct node{ int l, r; }; node a[1000005]; int n, ans=-1; void dfs 阅读全文
posted @ 2020-08-12 17:31 TFLSNOI 阅读(210) 评论(0) 推荐(0) 编辑
摘要:问题一:题意:输入一个整数n(n <= 9),输出1、2、3、······、n这n个数的全排列(按照字典序输出)。 方法1:暴力写法 1 #include<bits/stdc++.h> 2 using namespace std; 3 4 int main(){ 5 int n=3, a[20];/ 阅读全文
posted @ 2019-11-28 09:15 TFLSNOI 阅读(644) 评论(0) 推荐(0) 编辑
摘要:有向图、无向图,DFS和BFS的不同遍历方式:https://segmentfault.com/a/1190000010348783 阅读全文
posted @ 2019-08-03 08:16 TFLSNOI 阅读(226) 评论(0) 推荐(0) 编辑
摘要:题目链接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1335 方法一:dfs 方法二:bfs:STL优美展示--笑脸 方法三:并查集???大佬博客传送门 一种题多种写法,深化对算法对理解 【类型题扩展】 四连通》》八连通(什么鬼https://bl 阅读全文
posted @ 2018-12-24 17:06 TFLSNOI 阅读(4545) 评论(0) 推荐(0) 编辑
摘要:相关题连接: 一本通:http://ybt.ssoier.cn:8088/problem_show.php?pid=1215 小白菜OJ:http://caioj.cn/problem.php?id=1037 一、DFS写法: 问题一:迷宫是否能走通?(http://ybt.ssoier.cn:80 阅读全文
posted @ 2018-10-03 13:12 TFLSNOI 阅读(468) 评论(0) 推荐(0) 编辑
摘要:描述 给出一个正整数a,要求分解成若干个正整数的乘积,即a = a1 * a2 * a3 * ... * an,并且1 < a1 <= a2 <= a3 <= ... <= an,问这样的分解的种数有多少。注意到a = a也是一种分解。 输入 第1行是测试数据的组数n,后面跟着n行输入。每组测试数据 阅读全文
posted @ 2018-09-18 17:43 TFLSNOI 阅读(1615) 评论(0) 推荐(1) 编辑
摘要:【题目描述】 棋盘上A点有一个过河卒,需要走到目标B点。卒行走的规则:可以向下、或者向右。同时在棋盘上的某一点有一个对方的马(如C点),该马所在的点和所有跳跃一步可达的点称为对方马的控制点,如图3-1中的C点和P1,……,P8,卒不能通过对方马的控制点。棋盘用坐标表示,A点(0,0)、B点(n, m 阅读全文
posted @ 2018-09-07 23:13 TFLSNOI 阅读(6354) 评论(0) 推荐(0) 编辑
摘要:题目连接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1196 知乎题解https://zhuanlan.zhihu.com/p/61240921 (动态规划) 备递推算法的时候遇到这道题,没有发现递推式,看完网路题解才能推出来 题解如右连接,看完恍 阅读全文
posted @ 2018-09-06 23:20 TFLSNOI 阅读(2125) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示