hdu 1532 最大流
来源:互联网 发布:dw制作淘宝尺码表格 编辑:程序博客网 时间:2024/06/03 03:54
#include <cstdio>#include <iostream>#include <algorithm>#include <queue>#include <cmath>#include <cstring>#include <stack>#include <set>#include <map>#include <vector>using namespace std;#define INF 0x4fffffff#define LL long long#define MAX(a,b) ((a)>(b))?(a):(b)#define MIN(a,b) ((a)<(b))?(a):(b)int n,m;LL c[205][205];LL f[205][205];LL a[205];LL pre[205];void max_flow(){memset(f,0,sizeof(f));LL ans = 0;while(1){memset(a,0,sizeof(a));queue<int> que;que.push(1);a[1] = INF;while(!que.empty()){int u = que.front();que.pop();for(int i = 1;i <= m;i++){if(!a[i] && c[u][i] > f[u][i]){pre[i] = u;a[i] = min(a[u],c[u][i] - f[u][i]);que.push(i);}}}if(a[m] == 0) break;for(int u = m; u!=1;u = pre[u]){f[pre[u]][u] += a[m];f[u][pre[u]] -= a[m];}ans += a[m];}cout << ans << endl; }int main(){while(scanf("%d%d",&n,&m)!=EOF){memset(c,0,sizeof(c));for(int i = 0;i < n;i++){int x,y,w;scanf("%d%d%d",&x,&y,&w);c[x][y] += w;}max_flow();}return 0;}
0 0
- hdu 1532 最大流
- hdu 1532(最大流)
- hdu 1532 最大流模板
- hdu 1532 网络流-最大流 DINIC
- 图论 网络流 HDU 1532 最大流
- HDU-1532-网络流最大流
- HDU 1532 Drainage Ditches (最大网络流)
- HDU 1532 Drainage Ditches (最大网络流)
- hdu 1532 Drainage Ditches(最大网络流)
- hdu 1532 最简单的最大流
- hdu 1532 Drainage Ditches 基础最大流
- hdu 1532 && poj 1273 (基础最大流)
- hdu 1532 Drainage Ditches 最大流
- hdu 1532 Drainage Ditches (最大流)
- hdu 1532&&poj1273 基础最大流
- [hdu 1532] Drainage Ditches(最大流dinic)
- HDU 1532 最大流,EK算法
- hdu 1532 Drainage Ditches(最大流)
- opencv用形态学方法行计算文字角度
- Comparable与Comparator的区别
- sql Server 三范式
- ZooKeeper分布式集群部署及问题
- IOS开发—NSDateFormatter
- hdu 1532 最大流
- linux 精灵函数
- 《产品36记》目录
- Angular简要概述一些概念
- HDU 5312-Sequence(三角形数+推导)
- [Tue, 21 Jul 2015 ~ Mon, 27 Jul 2015] Deep Learning in arxiv
- Log日志记录buildMessage
- [****ViewController scrollViewDidScroll:]: message sent to deallocated instance 0x12d6c22f0
- tomcat结合nginx使用小结