洛谷.3254.圆桌问题(最大流ISAP)】的更多相关文章

题目链接 日常水题 还是忍不住吐槽这题奇怪的评价 #include <cstdio> #include <cctype> #include <algorithm> #define gc() getchar() //#define gc() (SS==TT&&(TT=(SS=IN)+fread(IN,1,MAXIN,stdin),SS==TT)?EOF:*SS++) const int N=450,M=5e4+5,INF=0x3f3f3f3f,MAXIN=…
题意 $m$个不同单位代表参加会议,第$i$个单位有$r_i$个人 $n$张餐桌,第$i$张可容纳$c_i$个代表就餐 同一个单位的代表需要在不同的餐桌就餐 问是否可行,要求输出方案 Sol 比较zz的最大流 从$S$向$1-m$连流量为$r_i$的边 从$m + 1$向$m + n$连流量为$c_i$的边 从$1-m$向$m + 1$到$m + n$中的每个点连流量为$1$的边 跑最大流即可 #include<cstdio> #include<queue> #include<…
题目链接 嗯..水题 洛谷这网络流二十四题的难度评价真神奇.. #include <queue> #include <cstdio> #include <cctype> #include <cstring> #include <algorithm> #define gc() getchar() const int N=206,M=15000,INF=0x3f3f3f3f; int n,m,src,des,A[N],B[N],C[N][N],dis…
传送门 一道良心啊……没那么多麻烦了…… 从$S$向所有单位连边,容量为单位人数,从所有桌子向$T$连边,容量为桌子能坐的人数,从每一个单位向所有桌子连边,容量为$1$,然后跑一个最大流,看一看$S$到单位这一边流满了没,如果没有就无解.方案的话,就看单位到哪一个桌子有流就行 因为手写队列然后两个$t$弄混了结果死都不知道哪里错…… //minamoto #include<iostream> #include<cstdio> #include<cstring> #inc…
s向所有单位连流量为人数的边,所有饭桌向t连流量为饭桌容量的边,每个单位向每个饭桌连容量为1的边表示这个饭桌只能坐这个单位的一个人.跑dinic如果小于总人数则无解,否则对于每个单位for与它相连.满流.另一端不是s的点则是最终方案 #include<iostream> #include<cstdio> #include<queue> #include<cstring> using namespace std; const int N=1000005,inf…
简单最大流建图 #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <queue> using namespace std; const int MAXN=600,MAXM=2000005; int head[MAXN],cur[MAXN],n,m,s,t,nume,num1[MA…
费用流板子 还是一道板子题..先练练手 #include <bits/stdc++.h> #define INF 0x3f3f3f3f #define full(a, b) memset(a, b, sizeof a) using namespace std; typedef long long ll; inline int lowbit(int x){ return x & (-x); } inline int read(){ int X = 0, w = 0; char ch =…
传送门 源点向仓库连费用$0$,流量为储量的边,商店向汇点连费用$0$,流量为需求的边,然后仓库向商店连流量$inf$,费用对应的边,跑个费用流即可 //minamoto #include<iostream> #include<cstdio> #include<queue> #include<cstring> #define inf 0x3f3f3f3f using namespace std; #define getc() (p1==p2&&…
传送门 可以把原图看做一个二分图,人在左边,任务在右边,求一个带权的最大和最小完美匹配 然而我并不会二分图做法,所以只好直接用费用流套进去,求一个最小费用最大流和最大费用最大流即可 //minamoto #include<iostream> #include<cstdio> #include<queue> #include<cstring> #define inf 0x3f3f3f3f using namespace std; #define getc()…
https://www.luogu.org/problemnew/show/P4452 又一道看题解的费用流. 注意时间也影响节点,像题解那样建边就少很多了. #include<bits/stdc++.h> using namespace std; +; ; const int INF=0x3f3f3f3f; struct Edge{ int to,next,cap,flow,cost; }edge[MAXM]; int head[MAXN],tol; int pre[MAXN],dis[MA…