[codevs 1993]草地排水
来源:互联网 发布:淘宝确认收货能退款吗 编辑:程序博客网 时间:2024/04/26 03:42
#include<cstdio>#include<queue>#include<cstring>#define maxn 205using namespace std;int n,m;int flow[maxn][maxn],cap[maxn][maxn],d[maxn],father[maxn];queue<int> q;int ans;int main(){scanf("%d%d",&n,&m);int s,e,c;for(int i=1;i<=n;i++){scanf("%d%d%d",&s,&e,&c);cap[s][e]+=c;}for(;;){memset(d,0,sizeof(d));q.push(1);d[1]=1e9;while(!q.empty()){int p=q.front();q.pop();for(int i=1;i<=m;i++){if(!d[i]&&cap[p][i]>flow[p][i]){father[i]=p;d[i]=min(d[p],cap[p][i]-flow[p][i]);q.push(i);}}}if(d[m]==0)break;for(int i=m;i!=1;i=father[i]) { flow[father[i]][i]+=d[m]; flow[i][father[i]]-=d[m]; } ans+=d[m];}printf("%d",ans);return 0;}
0 0
- [codevs 1993]草地排水
- Codevs 1993 草地排水
- codevs 1993草地排水
- Codevs 1993 草地排水 [dinic] [最大流]
- 【codevs 1993】草地排水(最大流)
- 【codevs 1993】草地排水【Dinic裸题】
- dinic codevs 1993 草地排水题解
- CodeVS 1993 草地排水 E-K网络流初步
- codevs 草地排水问题 网络流
- 草地排水
- 【Drainage Ditches 草地排水】
- 【wikioi1993】草地排水
- 【wikioi1993】 草地排水
- codevs1993 草地排水
- USACO草地排水
- code vs 草地排水
- Codevs1993草地排水
- 问题 A: 草地排水
- Codeforces Round #277 (Div. 2) A·B·C
- TF10121: 路径“{0}”找不到或不受支持。请键入或选择其他路径
- 【慕课笔记】4-2 字节流之文件输入流FileInputStream-2
- 【EJB基础】简单概述
- 如何成长的苦恼
- [codevs 1993]草地排水
- FIB、RIB、ARP、FDB的关系
- Android内存优化大全
- c3p0、dbcp比较
- HDU 5443 The Water Problem RMQ/暴力
- 历届试题 城市建设
- 在Android中作为服务端开启socket连接
- 深入PHP 双等号 详解
- iOS9后https不能请求问题解决的办法之一