随笔分类 - 搜索与图论
摘要:复杂度 点击查看代码 #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;
阅读全文
摘要:点击查看代码 #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
阅读全文
摘要:点击查看代码 #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
阅读全文
摘要:点击查看代码 #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
阅读全文
摘要:复杂度 点击查看代码 #include<iostream> #include<cstring> #include<queue> using namespace std; typedef pair<int, int> PII; const int N = 1e6 + 1
阅读全文
摘要:复杂度 点击查看代码 #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
阅读全文
摘要:点击查看代码 #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
阅读全文
摘要:点击查看代码 #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
阅读全文
摘要:点击查看代码 #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
阅读全文
摘要:点击查看代码 #include<iostream> #include<queue> #include<unordered_map> using namespace std; int bfs(string start) { string end = "12345678x"; queue<string>
阅读全文
摘要:BFS 使用STL中的queue 点击查看代码 #include<iostream> #include<cstring> #include<queue> using namespace std; typedef pair<int, int> PII; const int N = 100 + 10;
阅读全文
摘要:DFS 按行枚举 时间复杂度 点击查看代码 #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
阅读全文
摘要:点击查看代码 #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
阅读全文
摘要:点击查看代码 #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 +
阅读全文