POJ1459 Power Network 网络最大流

【小峰の题单】网络流经典题目 文章目录【小峰の题单】网络流经典题目1.最大流/最小割/二分图匹配P2756 飞行员配对方案问题「伪模板」主席树最小路径覆盖问题教辅的组成[ZJOI2009]狼和羊的故事[SCOI2007]蜥蜴方格取数问题[ICPC-Beijing 2006]狼抓兔子最长不下降子序列问题[国家集训队]happiness文理分科[清华集训2012]最小生成树[SHOI2007]善意的投票 / [JLOI2010]冠军调查[国家集训队]部落战争[TJOI2013]攻击装置[SHOI2010]最小生成树2.费用流负载平衡问题餐 阅读详情
这道题目描述了很多,其实就是每条边有一个输送容量,每个consumer有一个最大消耗值,station有一个最大生产值。求最大的消耗量。
将station与源点相连,弧的容量为最大生产值。将consumer与汇点相连,弧的容量为最大消耗值,在更具题目中所给的边的信息将各节点相连。
Power Network
Time Limit: 2000MS Memory Limit: 32768K
Total Submissions: 18221 Accepted: 9596

Description

A power network consists of nodes (power stations, consumers and dispatchers) connected by power transport lines. A node u may be supplied with an amount s(u) >= 0 of power, may produce an amount 0 <= p(u) <= pmax(u) of power, may consume an amount 0 <= c(u) <= min(s(u),cmax(u)) of power, and may deliver an amount d(u)=s(u)+p(u)-c(u) of power. The following restrictions apply: c(u)=0 for any power station, p(u)=0 for any consumer, and p(u)=c(u)=0 for any dispatcher. There is at most one power transport line (u,v) from a node u to a node v in the net; it transports an amount 0 <= l(u,v) <= lmax(u,v) of power delivered by u to v. Let Con=Σuc(u) be the power consumed in the net. The problem is to compute the maximum value of Con.

An example is in figure 1. The label x/y of power station u shows that p(u)=x and pmax(u)=y. The label x/y of consumer u shows that c(u)=x and cmax(u)=y. The label x/y of power transport line (u,v) shows that l(u,v)=x and lmax(u,v)=y. The power consumed is Con=6. Notice that there are other possible states of the network but the value of Con cannot exceed 6.

Input

There are several data sets in the input. Each data set encodes a power network. It starts with four integers: 0 <= n <= 100 (nodes), 0 <= np <= n (power stations), 0 <= nc <= n (consumers), and 0 <= m <= n^2 (power transport lines). Follow m data triplets (u,v)z, where u and v are node identifiers (starting from 0) and 0 <= z <= 1000 is the value of lmax(u,v). Follow np doublets (u)z, where u is the identifier of a power station and 0 <= z <= 10000 is the value of pmax(u). The data set ends with nc doublets (u)z, where u is the identifier of a consumer and 0 <= z <= 10000 is the value of cmax(u). All input numbers are integers. Except the (u,v)z triplets and the (u)z doublets, which do not contain white spaces, white spaces can occur freely in input. Input data terminate with an end of file and are correct.

Output

For each data set from the input, the program prints on the standard output the maximum amount of power that can be consumed in the corresponding network. Each result has an integral value and is printed from the beginning of a separate line.

Sample Input

2 1 1 2 (0,1)20 (1,0)10 (0)15 (1)20
7 2 3 13 (0,0)1 (0,1)2 (0,2)5 (1,0)1 (1,2)8 (2,3)1 (2,4)7
         (3,5)2 (3,6)5 (4,2)7 (4,3)5 (4,5)1 (6,0)5
         (0)5 (1)2 (3)2 (4)1 (5)4

Sample Output

15
6

Hint

The sample input contains two data sets. The first data set encodes a network with 2 nodes, power station 0 with pmax(0)=15 and consumer 1 with cmax(1)=20, and 2 power transport lines with lmax(0,1)=20 and lmax(1,0)=10. The maximum value of Con is 15. The second data set encodes the network from figure 1.
 
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>

using namespace std;

#define MAXN 110
#define INF 0xFFFFFF
#define mm(a) memset((a),0,sizeof((a)))

int n,np,nc,m,c[MAXN][MAXN],dis[MAXN],gap[MAXN],st,ed;

int sap(int u,int flow)
{
	if(u==ed)
		return flow;
	int ans=0,i,t;
	for(i=0;i<=n+1;++i)
		if(c[u][i]&&dis[u]==dis[i]+1)
		{
			t=sap(i,min(flow-ans,c[u][i]));
			c[u][i]-=t,c[i][u]+=t,ans+=t;
			if(ans==flow)
				return ans;
		}
	if(dis[st]>=n+2)
		return ans;
	if(!--gap[dis[u]])   
		dis[st]=n+2;
	++gap[++dis[u]];
	return ans;
}

void init()
{
	int a,b,c_;
	mm(c),mm(dis),mm(gap);
	for(int i=1;i<=m;i++)
	{
		scanf(" (%d,%d)%d",&a,&b,&c_);
		c[a+1][b+1]+=c_;
	}
	for(int i=1;i<=np;i++)
	{
		scanf(" (%d)%d",&a,&b);
		c[0][a+1]+=b;
	}
	for(int i=1;i<=nc;i++)
	{
		scanf(" (%d)%d",&a,&b);
		c[a+1][n+1]+=b;
	}
	st=0,ed=n+1;
}

int main()
{
	while(scanf("%d%d%d%d",&n,&np,&nc,&m)!=EOF)
	{
		int ans=0;
		init();
		for(gap[0]=n+2;dis[st]<n+2;)    
			ans+=sap(st,INF);
		printf("%d\n",ans);
	}
	return 0;
}



华为AR6140E/S5735设备密码策略配置全攻略:从复杂度到锁定机制 本文详细介绍了华为AR6140E/S5735设备的密码策略配置方法,涵盖密码复杂度、时效性和防护性三大核心维度。通过具体的CLI命令示例,指导管理员如何设置密码长度、字符组合、有效期及登录失败锁定等安全机制,为企业网络提供全面的用户名密码防护策略。 阅读详情

相关推荐

用STM32手搓一个体温计

市面上大多额温计、测温计精度。

m0_61687959的博客 2380

1459 Power Network 网络流 SAP

Power Network Time Limit: 2000MS   Memory Limit: 32768K Total Submissions: 10412   Accepted: 5705 Description A

kongming_acm的专栏 569

逆向分析踩坑记:当Frida在x86模拟器上‘看不见’ARM的so文件时,我们该如何手动定位与验证?

本文探讨了在x86模拟器上使用Frida进行逆向分析时,无法检测到ARM架构so文件的解决方案。通过分析内存映射、Frida的视觉盲区及手动定位技术,提供了兼容层、混合调试和原生ARM环境三种实用方案,帮助逆向工程师突破工具限制,实现精准定位与验证。

weixin_27697385的博客 226

poj1459多源点网络流入门

poj1459多源点网络流入门 题目链接:http://poj.org/problem?id=1459 题目部分 题意: 简单的说下题意(按输入输出来讲,前面的描述一堆的rubbish,还用来误导人),给你n个点,其中有np个是能提供电力的点,nc个是能消费电力的点,剩下的点(n-np-nc)是中转战即不提供电力也不消费电力,点与点之间是有线路存在的,有m条线路,每条线路有最多运载限定。 前4个

formicary的专栏 3425

立创开源:基于STM32F407的大疆M30T无人机PSDK机载开发板硬件设计与飞行控制实现

本文详细介绍了基于STM32F407微控制器为大疆M30T无人机设计PSDK机载开发板的完整流程。从关键的E-Port接口电路设计、电源保护,到STM32最小系统搭建,再到通过PSDK实现与无人机的通信及基础飞行控制,提供了从硬件到软件的全栈实战指南,助力开发者快速入门无人机负载开发。

weixin_35649491的博客 410

Sentinel2 哨兵2数据下载方法(USGS)-史上最全讲解

本文讲述了从USGS官网下载Sentinel2的方法。主要包括USGS官网的注册和下载流程,以及选定研究区中所出现的问题、解决办法。

xiatiandexia123的博客 6万+

算法导论学习笔记第26章 & acm专题训练7——最大流

26最大流 1.研究的问题 可以把最大流问题用货运公司的运货来模拟。有一个源点持续不断地产生新货物,并通过有限条道路运往一个汇点,每条道路有限定的容量,且进入一个节点的速度和出一个节点的速度相同。求源点到汇点的最大速率。 2.运用算法条件 容量值为非负数,对于两个节点,u,v,(u,v)与(v,u)至多存在一个,如果不连通,令c(u,v)=0,不允许自循环,图必须连通. c(u,v)指的是容量,f...

HDUCheater的博客 1029

[苹果开发者账号]03 申请APPID、苹果开发者账号 常见问题整理

目录:问题持续更新问题一:提示:抱歉,您暂时不能注册问题二:Apple Developer Support提示:联系我们以继续流程 问题一:提示:抱歉,您暂时不能注册 申请苹果开发者账号,应该先注册AppleID,由于很多都是申请的公司使用的苹果开发者账号。一般操作申请动作的人,可能是新手操作,也可能图方便,有些信息会随便填写。 有些人会把姓名填写为,公司的产品、简称、缩写等等。这是不对的。 还有出生日期也会随便乱填。生日如果填写的不对,会被苹果限制使用一些功能的(苹果给的提示不是太明确)。 当生日填写的

专注于技术开发、项目管理 1万+

(网络流)最大流-增广路算法

网络流-最大流 详细讲解

Never_gonna的博客 2054

手把手教你用Vivado配置Xilinx SEM IP 3.1(附Tera Term串口调试全流程)

本文详细介绍了如何使用Vivado配置Xilinx SEM IP 3.1,包括工程创建、IP参数调整、VIO工具应用以及Tera Term串口调试的全流程。通过手把手教程,帮助开发者快速掌握SEM IP的配置方法,实现存储器软错误的检测与纠正,提升FPGA开发效率。

weixin_30216561的博客 371

通信原理 | 随机数仿真 | 均匀、正态、双高斯、瑞利、莱斯、对数正态、nakagami、Suzuki分布的随机数仿真(matlab)

信道建模在通信系统设计和分析中扮演着至关重要的角色。它指的是使用数学和物理模型来描述和模拟无线或有线通信路径中的信号传播特性。

若北辰 1996

poj 1459 Power Network (网络最大流)

Description A power network consists of nodes (power stations, consumers and dispatchers) connected by power transport lines. A node u may be supplied with an amount s(u) >= 0 of po...

bandiaodai5734的博客 191

面向企业架构师的 SAP BTP 全景实践:多云、账户、运行时与端到端开发路径

摘要:SAP BTP为企业提供多云、多运行时(Cloud Foundry/Kyma/ABAP Cloud)的数字化转型平台,支持快速构建扩展应用。关键选择包括:1)根据合规与性能选择区域;2)区分Trial(90天限制)与Free Tier(无期限)方案;3)按场景选择运行时(CF适合微服务/Kyma适合云原生/ABAP Cloud适合S/4HANA扩展)。建议优先使用Free Tier进行POC,并通过BTP Cockpit统一管理,实现从验证到生产的平滑过渡。(150字)

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 268

网络流--最大流--POJ 1459 Power Network

#include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<vector> #define INF 1e9 using namespace std; const int maxn=100+5; struct Edge { in...

日拱一卒,功不唐捐 2817

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

POJ 1459 & ZOJ 1734 Power Network (网络最大流)

http://poj.org/problem?id=1459 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1734 Power Network Time Limit: 2000MS   Memory Limit: 32768K Total Submissio

fcbruce 1217

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

poj-1459 Power Network(网络最大流问题)

Power Network Time Limit:2000MS     Memory Limit:32768KB  Description A power network consists of nodes (power stations, consumers and dispatchers) connected by power transport lines. A node u ma

AC之路 1441

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

POJ 1459Power Network(网络流之最大流)

题目地址:http://poj.org/problem?id=1459 题目很简单。。就是t

scf0920 909

POJ 1459 Power Network(网络流—最大流)

//网络流——最大流 //通过添加虚源点和虚汇点构图,转化为从源点到汇点的最短路 #include #include #include #define INF 2000000000 using namespace std; int n,np,nc,m; int x,y,c,p,f,maxflow,st,ed,u,v; int cap[105][105],flow[105][105]; int rflow[105],pre[105]; int main() { //freopen(

Czy 858

POJ - 1459 Power Network(网络流最大流)

POJ - 1459 题意:看题看的心累,其实就是所有power station是源点,所有consumer是汇点,然后就是一个最大流问题了~ 读入写的有点蠢,其实scanf(" ()") 这种就够啦~ 另外,对于单路增广的dinic来说,当前弧优化真的很有必要。#include <cstdio> #include <cstring> #include <algorithm> #include

shinimashzi 318

POJ - 1459 Power Network(网络流-最大流)

题目链接:点击查看 题目大意:题意属实恶心,借用别的大佬的题意: 题目描述 一个电网包含一些结点(电站、消费者、调度站),这些结点通过电线连接。每个结点 uu 可能被供给 s(u) 的电能, s(u)≥0 ,同时也可能产生 p(u)的电能, 0≤p(u)≤pmax(u),站点 u 还有可能 消费 c(u) 电能, 0≤c(u)≤min(s(u),cmax(u)),可能传输 d(u)的电能, ...

Falcon的博客 520

【Power Network】【POJ - 1459】(网络流-最大流)

题目: A power network consists of nodes (power stations, consumers and dispatchers) connected by power transport lines. A node u may be supplied with an amount s(u) &gt;= 0 of power, may produce an amo...

哇哈哈哈的博客 264

POJ 1459-Power Network(网络流_最大流)

Power Network Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1459 Description A power network consists of nodes (power stat

Inite的博客 532

【POJ - 1459】Power Network(网络流最大流,建图)

题干: A power network consists of nodes (power stations, consumers and dispatchers) connected by power transport lines. A node u may be supplied with an amount s(u) >= 0 of power, may produce an amo...

xuanweiace的博客 373

POJ--1459[Power Network] 网络最大流

分析:多源最大流问题,可以构造成一般最大流问题,增加一个超级源点s和一个超级汇点t即可。起点指向每个Power station,边的权值为Power station的Pmax。每个Consumer指向终点,边的权值为Cmax。Dispatcher看做一般节点。 感想:分别用EK和

___简言 667

poj1459(Power Network)网络最大流

Power Network Time Limit: 2000MS   Memory Limit: 32768K Total Submissions: 23426   Accepted: 12276 Description A power network consists of nodes (power stations, consumer

冰镇油条 451

poj1459 Power Network网络流最大流基础题

此题纯粹最大流没有变形,关键看懂英文 此题是网络流最大流关键是构图和sscanf的运用。此题是多起点多汇点。处理这类问题应该建立超级原点和超级汇点,原来的源点容量和汇点容量处理成超级源点到个源点的容量,各汇点的容量处理为汇点到超级汇点的容量 Power Network Time Limit: 2000MS Memory Limit: 32768K

lyc 1140
上一篇: POJ2112 Optimal Milking 网络最大流+二分
下一篇: POJ3469 Dual Core CPU 最小割
Albafica
博客等级 码龄16年 98粉丝 359原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值