博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU - 4289 Control (Dinic)
阅读量:4562 次
发布时间:2019-06-08

本文共 2678 字,大约阅读时间需要 8 分钟。

 You, the head of Department of Security, recently received a top-secret information that a group of terrorists is planning to transport some WMD 
1 from one city (the source) to another one (the destination). You know their date, source and destination, and they are using the highway network. 
  The highway network consists of bidirectional highways, connecting two distinct city. A vehicle can only enter/exit the highway network at cities only. 
  You may locate some SA (special agents) in some selected cities, so that when the terrorists enter a city under observation (that is, SA is in this city), they would be caught immediately. 
  It is possible to locate SA in all cities, but since controlling a city with SA may cost your department a certain amount of money, which might vary from city to city, and your budget might not be able to bear the full cost of controlling all cities, you must identify a set of cities, that: 
  * all traffic of the terrorists must pass at least one city of the set. 
  * sum of cost of controlling all cities in the set is minimal. 
  You may assume that it is always possible to get from source of the terrorists to their destination. 
------------------------------------------------------------ 
1 Weapon of Mass Destruction

Input  There are several test cases. 

  The first line of a single test case contains two integer N and M ( 2 <= N <= 200; 1 <= M <= 20000), the number of cities and the number of highways. Cities are numbered from 1 to N. 
  The second line contains two integer S,D ( 1 <= S,D <= N), the number of the source and the number of the destination. 
  The following N lines contains costs. Of these lines the ith one contains exactly one integer, the cost of locating SA in the ith city to put it under observation. You may assume that the cost is positive and not exceeding 10 7
  The followingM lines tells you about highway network. Each of these lines contains two integers A and B, indicating a bidirectional highway between A and B. 
  Please process until EOF (End Of File). 
Output  For each test case you should output exactly one line, containing one integer, the sum of cost of your selected set. 
  See samples for detailed information.Sample Input

5 65 35234121 55 42 32 44 32 1

Sample Output

3 题意: 在图中,删除点需要相应的花费,求最小的花费,使得s,t不连通。 思路: 最大流=最小割。 一开始忘记了,这个,想了半天费用流。。。 拆带限制点的流量即可。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define fuck(x) cerr<<#x<<" = "<
<
View Code

转载于:https://www.cnblogs.com/ZGQblogs/p/11215762.html

你可能感兴趣的文章
20165301 2017-2018-2 《Java程序设计》第四周学习总结
查看>>
Vue的简单入门
查看>>
urllib 中的异常处理
查看>>
通过SQL Server的扩展事件来跟踪SQL语句在运行时,时间都消耗到哪儿了?
查看>>
gulp
查看>>
pgsql查询优化之模糊查询
查看>>
不变模式
查看>>
20181227 新的目标
查看>>
androidtab
查看>>
php 事件驱动 消息机制 共享内存
查看>>
剑指offer 二叉树的bfs
查看>>
LeetCode Maximum Subarray
查看>>
让我们再聊聊浏览器资源加载优化
查看>>
underscore demo
查看>>
CSS hack
查看>>
浏览器全屏之requestFullScreen全屏与F11全屏
查看>>
软件包管理:rpm命令管理-安装升级与卸载
查看>>
旋转图像
查看>>
每日一小练——数值自乘递归解
查看>>
qq登陆错误提示
查看>>