随笔分类 -  搜索与图论

摘要:复杂度 O(n3) 点击查看代码 #include<iostream> using namespace std; const int N = 210, INF = 1e9; int n, m, k; int d[N][N]; void floyd() { for (int k = 1; 阅读全文
posted @ 2022-05-07 13:13 wKingYu 阅读(30) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<cstring> #include<queue> using namespace std; const int N = 1e5 + 10; int n, m; int h[N], e[N], ne[N], w[N], idx; i 阅读全文
posted @ 2022-05-07 11:07 wKingYu 阅读(23) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<cstring> #include<queue> using namespace std; const int N = 1e5 + 10; int n, m; int h[N], e[N], ne[N], w[N], idx; i 阅读全文
posted @ 2022-05-07 10:28 wKingYu 阅读(41) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<cstring> using namespace std; const int N = 510, M = 1e5 + 10; int n, m, k; int dist[N], last[N]; struct Edge { int 阅读全文
posted @ 2022-05-06 22:24 wKingYu 阅读(21) 评论(0) 推荐(0) 编辑
摘要:复杂度 O(mlog(n)) 点击查看代码 #include<iostream> #include<cstring> #include<queue> using namespace std; typedef pair<int, int> PII; const int N = 1e6 + 1 阅读全文
posted @ 2022-05-06 10:58 wKingYu 阅读(23) 评论(0) 推荐(0) 编辑
摘要:复杂度 O(n2) 点击查看代码 #include<iostream> #include<cstring> using namespace std; const int N = 510; int n, m; int g[N][N], dist[N]; bool st[N]; int d 阅读全文
posted @ 2022-05-06 09:40 wKingYu 阅读(21) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<cstring> #include<queue> using namespace std; const int N = 1e5 + 10; int n, m; int h[N], e[N], ne[N], idx; int d[N 阅读全文
posted @ 2022-05-06 08:55 wKingYu 阅读(33) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<cstring> #include<queue> using namespace std; const int N = 1e5 + 10; int n, m; int h[N], e[N], ne[N], idx; int d[N 阅读全文
posted @ 2022-05-05 23:37 wKingYu 阅读(33) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<cstring> using namespace std; const int N = 1e5 + 10, M = 2 * N; int n, ans = N; int h[N], e[M], ne[M], idx; bool s 阅读全文
posted @ 2022-05-05 22:57 wKingYu 阅读(43) 评论(0) 推荐(1) 编辑
摘要:点击查看代码 #include<iostream> #include<queue> #include<unordered_map> using namespace std; int bfs(string start) { string end = "12345678x"; queue<string> 阅读全文
posted @ 2022-05-05 15:06 wKingYu 阅读(27) 评论(0) 推荐(1) 编辑
摘要:BFS 使用STL中的queue 点击查看代码 #include<iostream> #include<cstring> #include<queue> using namespace std; typedef pair<int, int> PII; const int N = 100 + 10; 阅读全文
posted @ 2022-05-05 00:19 wKingYu 阅读(52) 评论(0) 推荐(1) 编辑
摘要:DFS 按行枚举 时间复杂度 O(n!) 点击查看代码 #include<iostream> using namespace std; const int N = 20; int n; char g[N][N]; bool col[N], dg[N], udg[N]; void dfs(in 阅读全文
posted @ 2022-05-04 23:04 wKingYu 阅读(36) 评论(0) 推荐(1) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 10; int n, path[N]; bool st[N]; void dfs(int u) { if (u > n) { for (int i = 1; i <= n; i 阅读全文
posted @ 2022-05-04 21:24 wKingYu 阅读(23) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; int n, m, ans = 0; void dfs(int x, int y) { if (x == n && y == m) ans ++; else { if (y < m) dfs(x, y + 阅读全文
posted @ 2022-04-15 23:07 wKingYu 阅读(26) 评论(0) 推荐(0) 编辑

欢迎阅读『搜索与图论』
点击右上角即可分享
微信分享提示