The terrorist group leaded by a well known international terrorist Ben Bladen is buliding a nuclear reactor to produce plutonium for the nuclear bomb they are planning to create. Being the wicked computer genius of this group, you are responsible for…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2314 The terrorist group leaded by a well known international terrorist Ben Bladen is buliding a nuclear reactor to produce plutonium for the nuclear bomb they are planning to create.…
Reactor Coolinghttp://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1314 Time Limit: 5 Seconds      Memory Limit: 32768 KB      Special Judge The terrorist group leaded by a well known international terrorist Ben Bladen is buliding a nuclear re…
题意:看是否有无源汇上下界可行流,如果有输出流量 题解:对于每一条边u->v,上界high,下界low,来说,我们可以建立每条边流量为high-low,那么这样得到的流量可能会不守恒(流入量!=流出量),这时我们要想使得流量守恒,我们需要建立附加流,附加流 是在刚才的图上的改进流,对于每一个点如果有流入量(in)>流出量(out),那么对于多余的流入量,我们需要想办法新加一条边流量为in-out流入该点,反之如果in<out,那么需要建立一条边流量为out-in流出该点,我们此时可以建立…
Destroy Transportation system Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)http://acm.hdu.edu.cn/showproblem.php?pid=4940 Problem Description Tom is a commander, his task is destroying his enemy’s transportatio…
 Description The terrorist group leaded by a well known international terrorist Ben Bladen is buliding a nuclear reactor to produce plutonium for the nuclear bomb they are planning to create. Being the wicked computer genius of this group, you are re…
贴个板子 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long ll; const int N=205, M=5e5+5, INF=1e9; inline ll read(){ char c=getchar();ll x=0,f=1; while(c<'0'||c>'9…
题目链接:https://nanti.jisuanke.com/t/31447 "Oh, There is a bipartite graph.""Make it Fantastic." X wants to check whether a bipartite graph is a fantastic graph. He has two fantastic numbers, and he wants to let all the degrees to between…
题意:给出一个n*m的矩阵的每行和及每列和,还有一些格子的限制,求一组合法方案. 源点向行,汇点向列,连一条上下界均为和的边. 对于某格的限制,从它所在行向所在列连其上下界的边. 求有源汇上下界可行流即可. 具体做法可以从汇点向源点连容量为正无穷的边,转成无源汇上下界可行流. 然后可以新建超级源汇,对于一条下界为l,上界为r的边(x,y),从超级源点向y,x向超级汇点连容量为l的边,x向y连容量为r-l的边. 如果那些容量为l的边没满流,则无解. #include <cstdio> #incl…
题意:给一些约束条件,要求算能否有可行流,ps:刚开始输入的是每一列和,那么就建一条上下界相同的边,这样满流的时候就一定能保证流量相同了,还有0是该列(行)对另一行每个点都要满足约束条件 解法:先按无源汇上下界可行流建边,然后添加一条从t到s的容量为inf的边,从超级源到超级汇跑一边最大流,看流量是不是等于新加边的流量和,注意这题有可能输入的数据会有锚段,那么我们需要特判一下是否有矛盾出现 还要注意的一点是:我刚开始是用string+cin读入的字符,但是出现了问题,导致我代码下面的那组数据不能…
题目链接: http://acm.sgu.ru/problem.php?contest=0&problem=194 题目大意: n个点(n<20000!!!不是200!!!RE了无数次),m条边(管子)(m范围好像没说,我开了10^6),每个点流入的和流出的液体要相等,每条边(管子)有上下界流量,问是否有解,有解YES无解NO,有解还要输出每条边的流量. 题目输入样例略坑,我以为要多组数据输入输出TEST #1 什么的.后来仔细看了Input发现只有一组吧应该,保险起见还是写了多组,但是不用…
[题目链接] http://poj.org/problem?id=2396 [题意] 知道一个矩阵的行列和,且知道一些格子的限制条件,问一个可行的方案. [思路] 设行为X点,列为Y点,构图:连边(s,Xi,sumXi,sumXi)(Yi,t,sumYi,sumYi)(Xi,Yj,down[i][j],up[i][j]). 则问题就是求一个有源汇点st的上下界可行流. 类似于 无源无汇上下界可行流 ,添加附加源汇点ST,边权转化为up-down,由ST向每个点连边保持流量平衡.然后添加(t,s,…
POJ2396 Budget 题意:n*m的非负整数矩阵,给出每行每列的和,以及一些约束关系x,y,>=<,val,表示格子(x,y)的值与val的关系,0代表整行/列都有这个关系,求判断是否有解并求一组解 建图显然 \[s \rightarrow _{[行和,行和]} x \rightarrow _{格子(x,y)的限制[l,r]} y \rightarrow_{[列和,列和]} t\] 有源汇上下界可行流 注意是非负整数 #include <iostream> #include…
http://fastvj.rainng.com/contest/236779#problem/G Description: n 行 m 列 给你行和 与 列和 然后有Q个限制,表示特定单元格元素大小的范围,最后问你可行的矩阵值 Solution: 有源汇上下界最大流问题,初始源点 连 行和流量是该行对应得行和,然后列连初始汇点,容量为列的列和,详细的限制,对应于行列之间,因为我最后要输出一个矩阵,所以n * m每一条边都要链接最后,手动连一条 t s inf的边,变成无源汇有上下界可行流问题,…
题目: Description We are supposed to make a budget proposal for this multi-site competition. The budget proposal is a matrix where the rows represent different kinds of expenses and the columns represent different sites. We had a meeting about this, so…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2406 这题,首先把题目那个式子的绝对值拆成两个限制,就成了网络流的上下界: 有上下界可行流原来只需要先流出下界,然后用超级源汇补足即可,原来的汇点向源点连一条下界0上界 inf 的边,就也流量守恒了: 竟然是枚举出错了囧,因为平时写的 S=0,所以枚举就是 S~T,但这回写的 S=n+1,枚举应该变成 1~T 啊! 代码如下: #include<cstdio> #include<c…
http://www.lydsy.com/JudgeOnline/problem.php?id=2406 设矩阵C=A-B 最小化 C 一行或一列和的最大值 整体考虑一行或者一列的和 二分最大值 这样每一行一列的和就有了范围 |Σai-Σbj|<=mid 去掉绝对值 Σai-mid <= Σbi <= Σai+mid 构图: 源点向行连下界为Σai-mid,上界为 Σai+mid 的边 列向汇点连下界为Σai-mid,上界为 Σai+mid 的边 第i行向第j列连下界为L,上界为R的边…
题目链接 上下界费用流: /* 每个点i恰好(最少+最多)经过一次->拆点(最多)+限制流量下界(i,i',[1,1],0)(最少) 然后无源汇可行流 不需要源汇. 注: SS只会连i',求SS->TT的最大流 该走的i->i'是不会不走的 */ #include<queue> #include<cstdio> #include<cctype> #include<cstring> #include<algorithm> #def…
Description The terrorist group leaded by a well known international terrorist Ben Bladen is buliding a nuclear reactor to produce plutonium for the nuclear bomb they are planning to create. Being the wicked computer genius of this group, you are res…
The terrorist group leaded by a well known international terrorist Ben Bladen is buliding a nuclear reactor to produce plutonium for the nuclear bomb they are planning to create. Being the wicked computer genius of this group, you are responsible for…
题目:Shoot the Bullet 收藏:http://www.tuicool.com/articles/QRr2Qb 把每一天看成一个点,每个女孩也看成一个点,增加源和汇s.t,源向每一天连上[0,d]的边,每一天与每个女孩如果有拍照任务的话连上[l,r]的边, 每个女孩与汇连上[g,oo]的边,于是构成一个有上下界的图. 所以这道题目我们可以转换一下,只要连一条T → S的边,流量为无穷,没有下界,那么原图就得到一个无源汇的循环流图. 接下来的事情一样:原图中的边的流量设成自由流量ci…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2406 二分答案.把 b 的 n 个行作为一排, m 个列作为一排,每行和每列之间连上下界为 L , R 的边,源点向每行连以 “ a 的该行的值的和” 加/减 mid 为上下界的边,每列向汇点连以 “ a 的该列的值的和” 加/减 mid 为上下界的边:然后跑可行流就行了. 自己把和超级源点及超级汇点的无关的边先连好了,到时候改一改容量就行了.但别忘了把 hd[ ] , cap[ ] ,…
最大值最小,所以考虑二分 |Σaij-Σbij|<=mid,所以Σbij的上下界就是(Σaij-mid,Σaij+mid) 考虑建有上下界网络,连接(s,i,Σaik-mid,Σaik+mid),(j,t,Σakj-mid,Σakj+mid),(i,j,l,r),如果有可行流这个mid就合法 跑可行流即可 #include<iostream> #include<cstdio> #include<cstring> #include<queue> usin…
Budget Time Limit: 5 Seconds      Memory Limit: 32768 KB      Special Judge We are supposed to make a budget proposal for this multi-site competition. The budget proposal is a matrix where the rows represent different kinds of expenses and the column…
题意 题解 二分答案+可行流判断. 模板题. CODE #include <cstdio> #include <cstring> #include <algorithm> #include <cctype> #include <queue> using namespace std; template<class T>inline void read(T &x) { char ch; int flg = 1; while(!is…
http://www.lydsy.com/JudgeOnline/problem.php?id=2055 某个国家必须经过vi次, 可以转化为上下界都为vi的边 对这张图做有源汇上下界可行最小费用流 按无源汇上下界可行流建好图,跑超级源点到超级汇点的最小费用最大流即可 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3442 题目大意: 一个屌丝给m个女神拍照,计划拍照n天,每一天屌丝给给定的C个女神拍照,每天拍照数不能超过D张,而且给每个女神i拍照有数量限制[Li,Ri],对于每个女神n天的拍照总和不能少于Gi,如果有解求屌丝最多能拍多少张照,并求每天给对应女神拍多少张照:否则输出-1. 解题思路: 有源汇带上下界的最大流,我也是第一次写. 说下建图: ①源点S到第i天流量为D[…
分析: 这道题乍一看……卧槽这都什么玩意…… 然后发现给了个A矩阵,要求一个可行的B矩阵,使得矩阵C=A-B的每一行的和的绝对值和每一列的和的绝对值的最大值最小…… 好拗口啊…… 什么最大值最小之类的,考的无非就是二分,我们二分一个答案,之后建图跑网络流. 因为要判断是否合法,所以我们想到了用有上下界的可行流,在这里我们采用有源汇的有上下界可行流. 我们把每行建点,第i行为xi,每列建点,第i列为yi,从S点到每行xi代表的点连边,容量为这一行的数值和±mid,从每一列yi代表的点向T点连边,容…
Description 176. Flow construction time limit per test: 1 sec. memory limit per test: 4096 KB input: standard output: standard You have given the net consisting of nodes and pipes; pipes connect the nodes. Some substance can flow by pipes, and flow s…
描述 ensokyo is a world which exists quietly beside ours, separated by a mystical border. It is a utopia where humans and other beings such as fairies, youkai(phantoms), and gods live peacefully together. Shameimaru Aya is a crow tengu with the ability…