PART1(算法思想简介)
1.实现:
2.时间复杂度:
3.特别优势:
4.适用情况:
5.需要注意的点:
6.函数、变量名的解释+英文:
7.dalao分析:
PART2(算法各种类型(并附上代码))
这个代码的格式还没调整


#include <iostream> #include <string.h> #include <queue> using namespace std; const int INF = 0x3f3f3f3f; const int MAX_N = 100; const int MAX_M = 10000; struct edge { int v, c, fail; } e[MAX_M]; int p[MAX_N], eid; void init() { memset(p, -1, sizeof(p)); eid = 0; } void insert(int u, int v, int c) { e[eid].v = v; e[eid].fail = p[u]; e[eid].c = c; p[u] = eid++; } void addedge(int u, int v, int c) { insert(u, v, c); insert(v, u, 0); } int S, T; int d[MAX_N]; bool bfs() {//平平无奇分分层罢了 memset(d, -1, sizeof(d)); queue<int> q; q.push(S); d[S] = 0; while(!q.empty()) { int u = q.front(); q.pop(); for(int i = p[u]; i != -1; i = e[i].fail) { int v = e[i].v; if(e[i].c > 0 && d[v] == -1) { q.push(v); d[v] = d[u] + 1; } } } return (d[T] != -1);//如果无法到达T了,算法也不必进行了 } int dfs(int u, int flow) { if(u == T) { return flow; } int res = 0; for(int i = p[u]; i != -1; i = e[i].fail) { int v = e[i].v; if(e[i].c > 0 && d[u]+1 == d[v])//c不为0才dfs,而flow一开始就不为0,为0了又马上break //故一旦dfs传递下去下去,一定是因为走不通而不是没给它起始流量,所以当res==0,就证明这个点走下去没意义,一滴流量也传不下去 { int tmp = dfs(v, min(flow, e[i].c)); flow -= tmp; e[i].c -= tmp; e[i^1].c += tmp; res += tmp; if(flow == 0) { break; } } } if(res == 0) { d[u] = -1; } return res; } int Dinic() { int res = 0; while(bfs()) { res += dfs(S, INF); } return res; } int main() { int n, m; init(); cin >> n >> m; for(int i = 0; i < m; ++i) { int u, v, flow; cin >> u >> v >> flow; addedge(u, v, flow); } cin >> S >> T; cout << Dinic() << endl; return 0; }
PART3(算法的延伸应用)
PART4(对算法深度的理解)
PART5(与其相关的有趣题目)