标准大白书式模板,代码简单但由于效率并不高,所以并不常用,就是这样

 #include<stdio.h>
#include<string.h>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const int maxm=+;
const int INF=0x3f3f3f3f; struct edge{
int from,to,c,f;
edge(int a,int b,int m,int n):from(a),to(b),c(m),f(n){}
}; struct ek{
int n,m;
vector<edge>e;
vector<int>g[maxm];
int a[maxm];
int p[maxm]; void init(int n){
for(int i=;i<n+;i++)g[i].clear();
e.clear();
} void add(int from,int to,int c){
e.push_back(edge(from,to,c,));
e.push_back(edge(to,from,,));
m=e.size();
g[from].push_back(m-);
g[to].push_back(m-);
} int mf(int s,int t){
int f=;
while(){
memset(a,,sizeof(a));
queue<int>q;
q.push(s);
a[s]=INF;
while(!q.empty()){
int u=q.front();
q.pop();
for(int i=;i<g[u].size();i++){
edge tmp=e[g[u][i]];
if(!a[tmp.to]&&tmp.c>tmp.f){
p[tmp.to]=g[u][i];
a[tmp.to]=min(a[u],tmp.c-tmp.f);
q.push(tmp.to);
}
}
if(a[t])break;
}
if(!a[t])break;
for(int i=t;i!=s;i=e[p[i]].from){
e[p[i]].f+=a[t];
e[p[i]^].f-=a[t]; }
f+=a[t];
}
return f;
}
};

最新文章

  1. python——协程
  2. Android FM 模块学习之四 源码解析(1)
  3. c sharp学习 问题记录
  4. (剑指Offer)面试题21:包含min函数的栈
  5. Chapter 8. Classes
  6. 九度OJ 1361 翻转单词顺序
  7. The Tips of Success(成功的建议)
  8. 修改一个Label上字体的大小(富文本)
  9. Python线程的常见的lock
  10. java之Spring(IOC)装配Bean(手动装配、自动装配、注解装配)
  11. Android Bundle详解
  12. WPF中在MVVM模式下,后台绑定ListCollectionView事件触发问题
  13. Spring Boot——Linux 启动方式
  14. 【Core】在mvc使用EF
  15. React-本地状态(state)
  16. kdTree相关原理及c++实现
  17. 【iOS】TableView的footerView不随cell滚动而停留在tableView底部的问题
  18. 三、Shiro授权开发
  19. 20155327 2016-2017-2 《Java程序设计》第一周学习总结
  20. JavaScript 核心

热门文章

  1. html css 伪样式
  2. PHP自带调试函数
  3. 实训10a--用数据值填充下拉列表
  4. codeforces 536a//Tavas and Karafs// Codeforces Round #299(Div. 1)
  5. kmp练习
  6. Tree Cutting (Hard Version) CodeForces - 1118F2 (树形DP,计数)
  7. 浅浅的分析LED呼吸灯的实现和PWM的关系
  8. mysql语句查询时间检测
  9. 字符串 dfs
  10. FREETEXTBOX