HDU 4289 Control 最小割】的更多相关文章

Control 题意:有一个犯罪集团要贩卖大规模杀伤武器,从s城运输到t城,现在你是一个特殊部门的长官,可以在城市中布置眼线,但是布施眼线需要花钱,现在问至少要花费多少能使得你及时阻止他们的运输. 题解:裸的最小割模型,最小割就是最大流,我们把点拆成2个点,然后将原点与拆点建边,流量为在城市建立眼线的费用,然后拆点为出点,原点为入点,将可以到达的城市之间建流量为无穷的边. 最后求出s 到 t的拆点的最大流 那么就是这个题目的答案了. 代码: #include<bits/stdc++.h> us…
HDU 4289 Control (网络流,最大流) Description You, the head of Department of Security, recently received a top-secret information that a group of terrorists is planning to transport some WMD(Weapon of Mass Destruction)from one city (the source) to another o…
http://acm.hdu.edu.cn/showproblem.php?pid=4289 Control Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2247    Accepted Submission(s): 940 Problem Description You, the head of Department of Secu…
Control Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2139    Accepted Submission(s): 904 Problem Description You, the head of Department of Security, recently received a top-secret informati…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2485 Destroying the bus stations Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2651    Accepted Submission(s): 891 Problem Description Gabi…
Problem A simple brute force problem (HDU 4971) 题目大意 有n个项目和m个问题,完成每个项目有对应收入,解决每个问题需要对应花费,给出每个项目需解决的问题以及各问题间的依赖关系,求最大利润. 解题分析 最大权闭合子图  用来解决一下有依赖关系的问题. X集权值为正,Y集权值为负.X集的某些点依赖于Y集,Y集的某些点互相依赖. 从S向X集的每个点连流量为权值的边,y集的每个点向T连流量为权值的边,若两个点互相依赖,则连一条权值为INF的边. 求一遍最…
海岸线 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=4859 Description 欢迎来到珠海! 由于土地资源越来越紧张,使得许多海滨城市都只能依靠填海来扩展市区以求发展.作为Z市的决策人,在仔细观察了Z市地图之后,你准备通过填充某些海域来扩展Z市的海岸线到最长,来吸引更多的游客前来旅游度假.为了简化问题,假设地图为一个N*M的格子,其中一些是陆地,一些是可以填充的浅海域,一些是不可填充的深海域.这里定义海岸线的长度为一个联通块陆地(可能包…
题目链接:https://vjudge.net/problem/HDU-4289 Control Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3829    Accepted Submission(s): 1610 Problem Description You, the head of Department of Security,…
Control Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5636    Accepted Submission(s): 2289 Problem Description You, the head of Department of Security, recently received a top-secret informati…
最小割 一个点拆成两个 AddEdge(i,i+N,x); 原图中的每条边这样连 AddEdge(u+N,v,INF); AddEdge(v+N,u,INF); S是源点,t+N是汇点.最大流就是答案. #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<vector> #include<queue> #include<algo…
Golden Eggs Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 673    Accepted Submission(s): 400 Problem Description There is a grid with N rows and M columns. In each cell you can choose to put a…
Pleasant sheep and big big wolf Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3316    Accepted Submission(s): 1360 Problem Description In ZJNU, there is a well-known prairie. And it attracts p…
题目链接 Solution 一眼看过去就是最小割,但是要求割边最少的最小的割. 所以要用骚操作... 建边的时候每条边权 \(w = w * (E+1) + 1;\) 那么这样建图跑出来的 \(maxflow\) 为原图 \(maxflow\) 的 \(E+1\) 倍加上割边数量. 割边数量很显然就是 \(maxflow~mod~(E+1)\). 我们很显然不能让割边数量大于模数,所以我们乘上的大数要比原有的边数多. 同时由于 \(maxflow\) 数值确定; 那么割边多的最小割肯定会长一些,…
题目:https://www.luogu.org/problemnew/show/P1344 就是求最小割: 但是还要边数最小,所以把边权都*1001+1,这样原来流量部分是*1001,最大流一样的不影响,而+1会使其尽量减少边数: bfs 里忘了给 dis[] 赋0了调了好半天...尴尬... 代码如下: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #i…
给一个无向图.告知敌人的起点和终点.你要在图上某些点安排士兵.使得敌人不管从哪条路走都必须经过士兵. 每一个点安排士兵的花费不同,求最小花费. 分析: 题意可抽象为,求一些点,使得去掉这些点之后,图分成了两部分.敌人的起点和终点分别在这两部分里. 即求最小割. 问题是最小割是边.这里把点拆成两个,自己到自己连边,边权为该点点权.其它题目给的边照连就能够了. 为了方便,对于点i,拆成(i,i+n). 因此,对于题目给的边(a,b),就连双向边边:(a+n,b,inf).(b+n,a,inf) #i…
如果我们先手拿完所有苹果再去考虑花费的话. S -> 摄像头 -> 苹果 -> T 就相当于找到一个最小割使得S和T分开. ans = sum - flow. 然后对于这一个模型, 我们可以不用网络流去解决. 我们从叶子出发,然后从下往上合并. 每次到一个节点的时候,我们先把摄像机所对应的影响去除. 然后把这个点的剩下流量传给父亲. 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen(&…
问题描述 LG1344 题解 我太菜了,我一开始竟然没有看出这是个最小割裸题... 两个询问. 第一个询问,直接跑最小割就好了. 第二个询问,建图的时候边权建 \(1\) ,代表割掉这条边需要 \(1\) 的代价. \(\mathrm{Code}\) #include<bits/stdc++.h> using namespace std; template <typename Tp> void read(Tp &x){ x=0;char ch=1;int fh; while…
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 destinatio…
题意: 有一群恐怖分子要从起点st到en城市集合,你要在路程中的城市阻止他们,使得他们全部都被抓到(当然st城市,en城市也可以抓捕).在每一个城市抓捕都有一个花费,你要找到花费最少是多少. 题解: 1 //首先这一道题我原本是想这用bfs来做,因为这就相当于一棵树,你就只需要找出来怎么把它截断就可以 2 //但是这种方法我没有尝试,我还是用的最大流.那个每一个城市可以拆点成两个,然后这两个城市之间的 3 //权值设为这个城市的驻扎成本,然后如果两个城市相连,比如x和y相连,那么就可以建(x+n…
题目链接 给出一些点, 每个点有一个权值, 给出一些边, 起点以及终点, 去掉一些点使得起点和终点不连通, 求最小的val. 拆点, 把一个点s拆成s和s', 之间建一条边, 权值为点权. 对于一条边, <u, v> 建边<u, v'>, <v, u'> 权值为inf, 跑一遍最大流. #include<bits/stdc++.h> using namespace std; #define pb(x) push_back(x) #define ll long…
#include<stdio.h> #include<string.h> #include<iostream> #define inf 0x3fffffff #define N 510 int n,ma[N][N],combine[N]; int seach(int &s,int &t) { int vis[N],i,j,tm,maxx,w[N]; memset(vis,0,sizeof(vis)); memset(w,0,sizeof(w)); tm=…
http://acm.hdu.edu.cn/showproblem.php?pid=4289 题意:有n个城市,m条无向边,小偷要从s点开始逃到d点,在每个城市安放监控的花费是sa[i],问最小花费可以监控到所有小偷. 思路:求最小割可以转化为最大流.每个城市之间拆点,流量是sa[i],再增加一个超级源点S和s相连,增加一个超级汇点T,让d的第二个点和T相连.然后就可以做了. #include <cstdio> #include <algorithm> #include <i…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4289 思路:求最小花费,最小割应用,将点权转化为边权,拆点,(i,i+n)之间连边,容量为在城市i的花费,然后就是若u,v之间有路,则连边(u+n,v),(v+n,u).最后就是跑最大流了. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<…
Control Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5023    Accepted Submission(s): 2067 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4289 Description: You, the head of Department of Secur…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=4289 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82835#problem/I 题意:有N个城市,现在城市S出现了一伙歹徒,他们想运送一些炸弹到D城市,不过警方已经得到了线报知道他们的事情,不过警察不知道他们所在的具体位置,所以只能采取封锁城市的办法来阻断暴徒,不过封锁城市是需要花费一定代价的,由于警局资金比较紧张,所以想知道如果完全阻…
[Link]:http://acm.hdu.edu.cn/showproblem.php?pid=4289 [Description] 给出一个又n个点,m条边组成的无向图.给出两个点s,t.对于图中的每个点,去掉这个点都需要一定的花费.求至少多少花费才能使得s和t之间不连通. [Solution] 最小割问题. 根据最大流最小割定理; 跑一次最大流即可; 因为是去掉点; 所以,把每个点转换成2个点; 2个点之间建一条边,容量为删掉它的花费. 这两个泛化出来的点,一个点作为原本点的"进点&quo…
view code//hdu 3987 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <queue> using namespace std; typedef long long ll; const ll INF = 1LL<<59; const ll E = 100001; const int N = 10…
Problem Description You may not hear about Nubulsa, an island country on the Pacific Ocean. Nubulsa is an undeveloped country and it is threatened by the rising of sea level. Scientists predict that Nubulsa will disappear by the year of 2012. Nubulsa…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3046 In ZJNU, there is a well-known prairie. And it attracts pleasant sheep and his companions to have a holiday. Big big wolf and his families know about this, and quietly hid in the big lawn. As ZJNU A…
题目地址:HDU 3452 最小割水题. 源点为根节点.再另设一汇点,汇点与叶子连边. 对叶子结点的推断是看度数是否为1. 代码例如以下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #include <math.h> #include <ctype.h> #include &l…