poj 1273 网络流
2017-02-24 18:41
405 查看
#include<iostream> #include<queue> #include<cstring> #include<cstdio> using namespace std; int res[202][202],minn,n,m,pre[202],a[202]; bool bfs(){ queue<int>q; q.push(1); int k; memset(a,0,sizeof(a)); a[1]=0x3f3f3f3f; while(!q.empty()){ k=q.front(); if(k==m) return 1; q.pop(); for(int i=1;i<=m;i++){ if(!a[i]&&res[k][i]){ q.push(i); pre[i]=k; a[i]=min(a[k],res[k][i]); } } } return 0; } int maxflow(){ int ans=0; while(bfs()){ ans+=a[m]; int k=m; while(k!=1){ res[pre[k]][k]-=a[m]; res[k][pre[k]]+=a[m]; k=pre[k]; } } return ans; } int main(){ // freopen("1.txt","r",stdin); int t1,t2,t3; while(cin>>n>>m){ memset(res,0,sizeof(res)); for(int i=1;i<=n;i++){ cin>>t1>>t2>>t3; res[t1][t2]+=t3; } cout<<maxflow()<<endl; } }
相关文章推荐
- POJ 1273Drainage Ditches --网络流最大流模板题
- Drainage Ditches - poj 1273(网络流模板)
- POJ1273_Drainage Ditches(网络流)
- poj 1273 Drainage Ditches(网络流模版题)
- hdu 1532(poj 1273) Drainage Ditches (网络流·最大流)
- POJ1273 Drainage Ditches (网络流)
- NYOJ 323 && HDU 1532 && POJ 1273 Drainage Ditches (网络流之最大流入门)
- poj 1273 裸 网络流 (dinic)
- 网络流 最大流 poj 1273
- POJ 1273 Drainage Ditches 网络流算法 .
- poj 1273 Drainage Ditches 【图论-网络流-最大流-Ford-Fulkerson】
- POJ 1273 网络流(最大流)模板
- POJ 1273 Drainage Ditches 网络流模版
- POJ 1273 - Drainage Ditches (网络流)
- 【网络流】poj 1273 Drainage Ditches
- POJ 1273(网络流-附hllp+sap模板)
- POJ 1273 Drainage Ditches 网络流 ISAP
- POJ-1273(网络流)
- poj 1273 Drainage Ditches (网络流_EK_入门)
- POJ 1273 Drainage Ditches 网络流 模板题