随笔分类 - 搜索与图论
摘要:DFS + 去重 复杂度 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 100 + 10; int n; char g[N][N]; int xa,
阅读全文
摘要: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
阅读全文
摘要: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 =
阅读全文
摘要:双向广搜 点击查看代码 #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
阅读全文
摘要: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];
阅读全文
摘要:二分 + 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
阅读全文
摘要:双端队列 BFS 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 500 + 10; const int INF = 0x3f3f3f3f; #define x first
阅读全文
摘要:BFS + 贪心 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; string start = "12345678"; map<string,int>
阅读全文
摘要:多源 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
阅读全文
摘要:带条件的 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
阅读全文
摘要: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;
阅读全文
摘要:BFS 最短路 + 记录方案 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; #define x first #define y second int
阅读全文
摘要: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;
阅读全文
摘要:需要处理输入的 Flood Fill 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; #define x first #define y second
阅读全文
摘要: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
阅读全文
摘要:点击查看代码 #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 >
阅读全文
摘要:点击查看代码 #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
阅读全文
摘要:点击查看代码 #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]
阅读全文
摘要:复杂度 点击查看代码 #include<iostream> #include<algorithm> using namespace std; const int N = 1e5 + 10, M = 2 * N, INF = 0x3f3f3f3f; int n, m;
阅读全文
摘要:点击查看代码 #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];
阅读全文