【wikioi1993】草地排水
来源:互联网 发布:云购cms 编辑:程序博客网 时间:2024/04/26 19:23
#include<iostream>#include<cstdio>#include<cstring>#define INF 0x7fffffffusing namespace std;struct data{int to,next,v;}e[402];int n,m,ne=1,ans;int h[201],q[201],head[201];void insert(int u,int v,int w){ ne++; e[ne].to=v;e[ne].v=w; e[ne].next=head[u]; head[u]=ne; ne++; e[ne].to=u; e[ne].next=head[v]; head[v]=ne; }bool bfs(){ memset(h,-1,sizeof(h)); int t=0,w=1,i,now; q[0]=1;h[1]=0; while(t<w) { now=q[t++];i=head[now]; while(i) { if(e[i].v&&h[e[i].to]==-1) {h[e[i].to]=h[now]+1;q[w++]=e[i].to;} i=e[i].next; } } if(h[n]==-1)return 0; return 1; }int dfs(int x,int f){ if(x==n)return f; int i=head[x],w,used=0; while(i) { if(e[i].v&&h[e[i].to]==h[x]+1) { w=f-used; w=dfs(e[i].to,min(e[i].v,w)); used+=w; e[i].v-=w; e[i|1].v+=w; if(used==f)return f; } i=e[i].next; } if(!used)h[x]=-1; return used;}void dinic(){while(bfs())ans+=dfs(1,INF);}int main(){ scanf("%d%d",&m,&n); for(int i=1;i<=m;i++) { int u,v,w; scanf("%d%d%d",&u,&v,&w); insert(u,v,w); } dinic(); printf("%d",ans); return 0;}
0 0
- 【wikioi1993】草地排水
- 【wikioi1993】 草地排水
- 草地排水
- 【Drainage Ditches 草地排水】
- codevs1993 草地排水
- USACO草地排水
- code vs 草地排水
- [codevs 1993]草地排水
- Codevs 1993 草地排水
- codevs 1993草地排水
- Codevs1993草地排水
- 问题 A: 草地排水
- 【CODEVS1993】【网络流】草地排水
- USACO 草地排水 网络流
- 【codevs1993】草地排水(isap)
- [POJ1273]草地排水 dinic模板
- 草地排水_codevs1993_网络流
- 网络流(草地排水)
- 错误 'Cannot run program "/home/uv/IDE/adt/sdk/platform-tools/adb": error=2, No such file or directory
- 这就是互联网思维 2013顶级营销案例盘点
- OpenGL之渲染优化
- XCode 5 “ios模拟器未能安装此应用程序”解决办法
- reference counting C complentation
- 【wikioi1993】草地排水
- Settings源代码分析之wifi高级界面
- WhatsApp的190亿估值高不高?
- 在线开发应用,Visual Studio Online 来了
- 百度地图API学习总结
- 设计网页的23条有用技巧
- 替换html中转义字符
- 【CCNA】计算机网络基础二 IP地址
- WWDC 2014大会发布!iOS8主打健康