随笔分类 -  搜索与图论

摘要:DFS + 去重 复杂度 O(n2) 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 100 + 10; int n; char g[N][N]; int xa, 阅读全文
posted @ 2022-08-07 22:19 wKingYu 阅读(18) 评论(0) 推荐(0) 编辑
摘要:A* 算法 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,string> PIS; const int N = 1e6 + 10; string start; in 阅读全文
posted @ 2022-08-07 13:36 wKingYu 阅读(32) 评论(0) 推荐(0) 编辑
摘要:A* 算法 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> PII; typedef pair<int,PII> PIPII; const int N = 阅读全文
posted @ 2022-08-06 18:24 wKingYu 阅读(9) 评论(0) 推荐(0) 编辑
摘要:双向广搜 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 10 + 10; int n; string A, B; string a[N], b[N]; queue<str 阅读全文
posted @ 2022-08-06 12:38 wKingYu 阅读(25) 评论(0) 推荐(0) 编辑
摘要:DFS + LCA 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; int n, m; int l[N], r[N], p[N]; int d[N]; 阅读全文
posted @ 2022-08-06 10:38 wKingYu 阅读(15) 评论(0) 推荐(0) 编辑
摘要:二分 + BFS 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 20000 + 10; int n, m; int h[N], e[N], ne[N], w[N], id 阅读全文
posted @ 2022-08-05 23:38 wKingYu 阅读(17) 评论(0) 推荐(0) 编辑
摘要:双端队列 BFS 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 500 + 10; const int INF = 0x3f3f3f3f; #define x first 阅读全文
posted @ 2022-08-05 22:41 wKingYu 阅读(26) 评论(0) 推荐(0) 编辑
摘要:BFS + 贪心 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; string start = "12345678"; map<string,int> 阅读全文
posted @ 2022-08-05 17:30 wKingYu 阅读(33) 评论(0) 推荐(0) 编辑
摘要:多源 BFS 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; #define x first #define y second int n, m; c 阅读全文
posted @ 2022-08-03 22:17 wKingYu 阅读(16) 评论(0) 推荐(0) 编辑
摘要:带条件的 BFS 最短路 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 10; int n, m; int d[N]; int bfs(int x) { qu 阅读全文
posted @ 2022-08-02 19:24 wKingYu 阅读(5) 评论(0) 推荐(0) 编辑
摘要:BFS 最短路 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; #define x first #define y second int n, m; 阅读全文
posted @ 2022-08-02 18:38 wKingYu 阅读(27) 评论(0) 推荐(0) 编辑
摘要:BFS 最短路 + 记录方案 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; #define x first #define y second int 阅读全文
posted @ 2022-08-02 18:24 wKingYu 阅读(17) 评论(0) 推荐(0) 编辑
摘要:Flood Fill 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; #define x first #define y second int n; 阅读全文
posted @ 2022-08-02 17:48 wKingYu 阅读(75) 评论(0) 推荐(0) 编辑
摘要:需要处理输入的 Flood Fill 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; #define x first #define y second 阅读全文
posted @ 2022-08-02 17:22 wKingYu 阅读(23) 评论(0) 推荐(0) 编辑
摘要:Flood Fill 问题 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; #define x first #define y second int 阅读全文
posted @ 2022-08-02 16:55 wKingYu 阅读(67) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 60; int n, res; int a[N], up[N], down[N]; void dfs(int u, int su, int sd) { if (su + sd > 阅读全文
posted @ 2022-06-17 22:48 wKingYu 阅读(16) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<cstring> using namespace std; const int N = 510, M = 1e5 + 10; int n1, n2, m; int h[N], e[M], ne[M], idx; bool st[N 阅读全文
posted @ 2022-05-07 23:25 wKingYu 阅读(25) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<cstring> using namespace std; const int N = 1e5 + 10, M = 2 * N; int n, m; int h[N], e[M], ne[M], idx; int color[N] 阅读全文
posted @ 2022-05-07 21:37 wKingYu 阅读(20) 评论(0) 推荐(0) 编辑
摘要:复杂度 O(mlog(m)) 点击查看代码 #include<iostream> #include<algorithm> using namespace std; const int N = 1e5 + 10, M = 2 * N, INF = 0x3f3f3f3f; int n, m; 阅读全文
posted @ 2022-05-07 15:23 wKingYu 阅读(27) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<iostream> #include<cstring> using namespace std; const int N = 510, INF = 0x3f3f3f3f; int n, m; int g[N][N]; int dist[N]; bool st[N]; 阅读全文
posted @ 2022-05-07 14:35 wKingYu 阅读(43) 评论(0) 推荐(0) 编辑

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