In the vast waters far far away, there are many islands. People are living on the islands, and all the transport among the islands relies on the ships.
  You have a transportation company there. Some routes are opened for passengers. Each route is a straight line connecting two different islands, and it is bidirectional. Within an hour, a route can transport a certain number of passengers in one direction. For safety, no two routes are cross or overlap and no routes will pass an island except the departing island and the arriving island. Each island can be treated as a point on the XY plane coordinate system. X coordinate increase from west to east, and Y coordinate increase from south to north.
  The transport capacity is important to you. Suppose many passengers depart from the westernmost island and would like to arrive at the easternmost island, the maximum number of passengers arrive at the latter within every hour is the transport capacity. Please calculate it.

题意:给出若干个点和点之间边的流量,问最西边的点到最东边的点的运量是多少

题意描述就是一个裸的网络流最大流问题,直接跑dinic就可以了

 #pragma comment(linker,"/STACK:16777216")
#include<stdio.h>
#include<string.h>
const int maxm=;
const int maxv=;
const int INF=0x3f3f3f3f; int s,t;
int n,m;
int d[maxm],cur[maxm];
bool vis[maxm];
int head[maxm],point[maxv],flow[maxv],nxt[maxv],size; void init(){
size=;
memset(head,-,sizeof(head));
} void add(int a,int b,int c){
point[size]=b;
flow[size]=c;
nxt[size]=head[a];
head[a]=size++;
point[size]=a;
flow[size]=c;
nxt[size]=head[b];
head[b]=size++;
} bool bfs(){
memset(vis,,sizeof(vis));
int q[maxm],cnt=;
q[++cnt]=s;
vis[s]=;
d[s]=;
for(int i=;i<=cnt;i++){
int u=q[i];
for(int j=head[u];~j;j=nxt[j]){
if(!vis[point[j]]&&flow[j]>){
d[point[j]]=d[u]+;
q[++cnt]=point[j];
vis[point[j]]=;
}
}
}
return vis[t];
} int dfs(int x,int a){
if(x==t||a==)return a;
int ans=,f;
for(int i=head[x];~i;i=nxt[i]){
if(d[point[i]]==d[x]+&&flow[i]>){
f=dfs(point[i],a<flow[i]?a:flow[i]);
flow[i]-=f;
flow[i^]+=f;
ans+=f;
a-=f;
if(a==)break;
}
}
if(ans==)d[x]=-;
return ans;
} int mf(){
int ans=;
while(bfs()){
ans+=dfs(s,INF);
}
return ans;
} int main(){
int T;
scanf("%d",&T);
for(int q=;q<=T;q++){ init();
scanf("%d%d",&n,&m);
int i,j,minx,maxx;
for(i=;i<=n;i++){
int x,y;
scanf("%d%d",&x,&y);
if(i==){
minx=x;
maxx=x;
s=t=i;
}
else{
if(x>maxx){
maxx=x;
s=i;
}
else if(x<minx){
minx=x;
t=i;
}
}
}
for(i=;i<=m;i++){
int a,b,v;
scanf("%d%d%d",&a,&b,&v);
add(a,b,v);
}
printf("%d\n",mf());
}
return ;
}

hdu4280 Island Transport 最大流的更多相关文章

  1. HDU4280 Island Transport —— 最大流 ISAP算法

    题目链接:https://vjudge.net/problem/HDU-4280 Island Transport Time Limit: 20000/10000 MS (Java/Others)   ...

  2. Hdu4280 Island Transport 2017-02-15 17:10 44人阅读 评论(0) 收藏

    Island Transport Problem Description In the vast waters far far away, there are many islands. People ...

  3. HDU4280 Island Transport

    ISAP求最大流模板 #include<cstdio> #include<cstring> #include<algorithm> #include<iost ...

  4. HDU4280:Island Transport(最大流)

    Island Transport Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  5. HDU 4280 Island Transport(网络流,最大流)

    HDU 4280 Island Transport(网络流,最大流) Description In the vast waters far far away, there are many islan ...

  6. Hdu 4280 Island Transport(最大流)

    Island Transport Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  7. HDU 4280 Island Transport(dinic+当前弧优化)

    Island Transport Description In the vast waters far far away, there are many islands. People are liv ...

  8. Island Transport

    Island Transport http://acm.hdu.edu.cn/showproblem.php?pid=4280 Time Limit: 20000/10000 MS (Java/Oth ...

  9. HDU 4280 Island Transport

    Island Transport Time Limit: 10000ms Memory Limit: 65536KB This problem will be judged on HDU. Origi ...

随机推荐

  1. Java中的标签

    @SuppressWarnings 简介:java.lang.SuppressWarnings是J2SE 5.0中标准的Annotation之一.可以标注在类.字段.方法.参数.构造方法,以及局部变量 ...

  2. linux 安装 DenyHosts 防止密码被暴力破解

    DenyHosts DenyHosts是Python语言写的一个程序,它会分析sshd的日志文件(/var/log/secure),当发现重 复的攻击时就会记录IP到/etc/hosts.deny文件 ...

  3. 如何写java求和源代码

    1.设计思想:利用eclipse编写. 2.程序流程图:先建立一个包->建立一个类->写代码->运行->修正错误,完善代码. 3.源程序代码: package dijia; p ...

  4. javascript进阶笔记(2)

    js是一门函数式语言,因为js的强大威力依赖于是否将其作为函数式语言进行使用.在js中,我们通常要大量使用函数式编程风格.函数式编程专注于:少而精.通常无副作用.将函数作为程序代码的基础构件块. 在函 ...

  5. js 变量的声明能提升 初始化不会提升

    var x = 5; // 初始化 x elem = document.getElementById("demo"); // 查找元素 elem.innerHTML = x + & ...

  6. jvm内存配置参数

    请看下面题目: 对于jvm内存配置参数: -Xmx10240m -Xms10240m -Xmn5120m -XXSurvivorRatio=3 其最小内存值和Survior区总大小分别是: a. 51 ...

  7. Unity中资源打包成Assetsbundle的资料整理

    最近在研究Unity中关于资源打包的东西,网上看了一堆资料,这里做个整合,说整合,其实也就是Ctrl-C + Ctrl-V,不是原创 首先为了尊重原创,先贴出原创者的文章地址: http://blog ...

  8. postman工具测试接口

    本篇文章主要介绍怎么在postman工具中进行接口的测试? 从以下几个方面进行介绍: 1.先介绍下接口测试 2.不同类型的接口请求方式如何在postman中进行测试 1.1 接口 什么是接口? 接口一 ...

  9. WebClient和WebRequest获取html代码

    HTML: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.as ...

  10. 在html5中不支持<table>的cellpadding 和 cellspacing ; 2) 如何用css实现 cellpadding, cellspacing ; 3) tr , th 是 有 border, 没有 padding 的.

    1.初始: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...