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, some t…
"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 the two boundaries. You can pick up seve…
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…
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…
https://nanti.jisuanke.com/t/31447 题意 一个二分图,左边N个点,右边M个点,中间K条边,问你是否可以删掉边使得所有点的度数在[L,R]之间 分析 最大流不太会.. 贪心做法: 考虑两个集合A和B,A为L<=d[i]<=R,B为d[i]>R 枚举每个边 1.如果u和v都在B集合,直接删掉2.如果u和v都在A集合,无所谓3.如果u在B,v在A,并且v可删边即d[v]>L4.如果u在A,v在B,并且u可删边即d[u]>L 最后枚举N+M个点判断是…
题意:给定一个矩阵的每行的和和每列的和,以及每个格子的限制,让你求出原矩阵. 析:把行看成X,列看成Y,其实就是二分图,然后每个X到每个Y边一条边,然后加一个超级源点和汇点分别向X和Y连边,这样就形成了一个有源汇有上下界的网络,如果有最大流,那么这个矩阵就存在. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #in…
第一步:建立无源汇有上下界的网络模型 每行 i 作为一个点并连边(s, i, Ri, Ri),每列 j 作为一个点并连边(j, t, Cj, Cj),设 Uij, Lij 分别表示第 i 行第 j 列元素的上下界,初始时设 Uij=∞, Lij=0.按照给定的约束条 件不断调整 Uij, Lij,若出现 Lij > Uij 的情况则已经不存在合法解.对所有元素加 边(i, j, Lij, Uij).另添加边(t, s, 0, ∞)消去原网络的源汇. 第二步:转化为最大流模型 新建源 s'和汇 t…
UVALive-7670 ICPC北京2016-C题 hihocoder 1424 题意 有个 \(N\times N\) 的棋盘,告诉你每个格子黑色(1)或白色(0),以及每对能相互交换的同行或同列格子,每个格子只在一对中,即共有\(N\times N /2\)对.求最少交换次数使得每行每列的黑格子总数满足给出的上下范围:若最终第i行,第j列分别有\(R[i],C[j]\)个黑格子,那么需要让\(Rl[i]\le R[i]\le Rh[i],Cl[j]\le C[i]\le Ch[j]\).…
[Loj117]有源汇上下界最小流(网络流) 题面 Loj 题解 还是模板题. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<set> #include<map> #include<vector> #include…
BZOJ_2502_清理雪道_有源汇上下界最小流 Description        滑雪场坐落在FJ省西北部的若干座山上. 从空中鸟瞰,滑雪场可以看作一个有向无环图,每条弧代表一个斜坡(即雪道),弧的方向代表斜坡下降的方向. 你的团队负责每周定时清理雪道.你们拥有一架直升飞机,每次飞行可以从总部带一个人降落到滑雪场的某个地点,然后再飞回总部.从降落的地点出发,这个人可以顺着斜坡向下滑行,并清理他所经过的雪道. 由于每次飞行的耗费是固定的,为了最小化耗费,你想知道如何用最少的飞行次数才能完成清…