本人2011级学生TXH大佬写的超短的SAP网络流程序
来源:互联网 发布:支配集网络matlab算法 编辑:程序博客网 时间:2024/06/05 11:26
/*ID:t-x.h1PROB:ditchLANG:C++*/#include<cstdio>#define min(a,b) ((a)<(b)?(a):(b))const int MAX=2100000000,MAXn=200+9;int n,answer,g[MAXn][MAXn],d[MAXn],gap[MAXn],st=1,ed=n;int sap(int u,int flow){if(u==ed)return flow;int res=flow,i,t;for(i=1;i<=n;++i)if(g[u][i] && d[u]==d[i]+1){t=sap(i,min(res,g[u][i]));g[u][i]-=t,g[i][u]+=t;if(!(res-=t))return flow;}if(!--gap[d[u]])d[st]=n;++gap[++d[u]];return flow-res;}int main(){int m,i,t1,t2,t3;freopen("ditch.in","r",stdin);freopen("ditch.out","w",stdout);scanf("%d%d",&m,&n);for(i=1;i<=m;++i){scanf("%d%d%d",&t1,&t2,&t3);g[t1][t2]+=t3;}for(gap[0]=n;d[st]<n;)answer+=sap(st,MAX);printf("%d\n",answer);return 0;}
阅读全文
0 0
- 本人2011级学生TXH大佬写的超短的SAP网络流程序
- 本人写的地区js
- 本人写博客的指导思想
- 超强超短的耗资源代码
- 超强超短的耗资源代码
- 配置超短的本地网址
- 超强超短的耗资源代码
- 有趣的超短Python代码
- 请各位大佬帮忙,本人遇到一个SQL语句的问题
- 本人学习的心得(随便写的)
- 本人最近写的Ajax留言板
- C++复习--本人写的Josephus问题
- 本人写的第一个 brainfuck 程序
- 本人自己写的一个银行系统
- 本人CSS3写的几面国旗
- 简历怎么写(集合自大佬的善意提醒)
- 分享一个用shell大佬写的--俄罗斯方块
- 连续数的最小公倍数(时间超短)
- 2222222
- 机器学习之-最邻近算法(Nearest Neighbor)
- Scala方法定义,方法和函数的区别,将方法转换成函数
- 找假币算法
- mac Android Studio安装kotlin插件
- 本人2011级学生TXH大佬写的超短的SAP网络流程序
- BZOJ2809(Apio2012)[dispatching]--左偏树
- 欢迎使用CSDN-markdown编辑器
- C#184课的主要内容
- SSM整合之参数绑定
- 异常
- linq to sql
- LeetCode-2. Add Two Numbers
- css实战之css画图