上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 19 下一页
摘要: 这道题注意要记录的是总步数,而不是当前步数 #include <iostream> #include <cstring> using namespace std; const int N = 105; char g[N][N]; int k, n; bool vis[N][N]; int sx, s 阅读全文
posted @ 2023-11-01 17:50 Gold_stein 阅读(1) 评论(0) 推荐(0) 编辑
摘要: dfs模板 #include <iostream> #include <cstring> using namespace std; const int N = 105; char g[N][N]; int k, n; bool vis[N][N]; int sx, sy, ex, ey; int d 阅读全文
posted @ 2023-11-01 11:33 Gold_stein 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 错误的等级区间限制: for(int st=l_min;st+Limit<=l_max;st++) 正确的等级区间限制: for(int st=l_min;st<=l_max;st++) 上限超了是没有任何影响的 完整代码: #include <stdio.h> #include <stdlib.h 阅读全文
posted @ 2023-10-26 09:41 Gold_stein 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 这道题实际上不需要最短路算法,因为每条边的边权都只有1 要注意在开始读入交通路线之前,要先把一个空行先读掉 这道题是“公交线路” 是有方向的 所以只能连单向边 #include <iostream> #include <cstring> #include <algorithm> #include < 阅读全文
posted @ 2023-10-25 13:10 Gold_stein 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 通过取对数把乘法变成加法,然后应用相对应的最短路算法 #include<algorithm> #include<queue> #include<stdio.h> #define R(x) x=read() using namespace std; const int N=2005; int n,m; 阅读全文
posted @ 2023-10-25 10:41 Gold_stein 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 换源点来不断进行单源最短路的计算。 #include <stdio.h> #include <stdlib.h> #include <queue> #include <algorithm> #include <cstring> #define R(x) x = read() using namesp 阅读全文
posted @ 2023-10-24 19:42 Gold_stein 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 这道题要求的就是最短路中的最大值 注意:Floyd算法中第一重循环是[1,n] 而不是[1,n),因为1~n中任何一个点都有可能是中转点。 #include <iostream> #include <algorithm> #include <cstring> using namespace std; 阅读全文
posted @ 2023-10-24 17:18 Gold_stein 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 最短路模板题 #include <stdio.h> #include <stdlib.h> #include <queue> #include <algorithm> #include <vector> #include <cstring> #define R(x) x = read() using 阅读全文
posted @ 2023-10-24 17:12 Gold_stein 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 179.八数码 估价函数:曼哈顿距离 #include <iostream> #include <cstring> #include <unordered_map> #include <sstream> #include <queue> #include <vector> #include <alg 阅读全文
posted @ 2023-10-23 19:09 Gold_stein 阅读(5) 评论(0) 推荐(0) 编辑
摘要: Dijkstra正确性证明 采用反证法+数学归纳法 设目前已经出对的点得到的都是最短路,那么对于现在刚好出队这个点t来说: 因为它是优先队列的对头,而且图中的边权都是非负数,所以它不可能被队列中的点再更新 因为每个点只会出队一次,所以它也不会被已经出队的点再次更新 还没有入队的点距离更远,也不可能再 阅读全文
posted @ 2023-10-19 18:29 Gold_stein 阅读(4) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 19 下一页