题目大意:有N个人在收集贴纸。现在给出每个人所拥有的贴纸
然后1这个想要得到更多种类的贴纸,所以他要拿他的贴纸去跟别人换,换的条件是1张交换1张,且你所交换的那张贴纸的种类对方没有,你想要得到的贴纸的种类对方至少有2张,问最后这个人能得到多少种贴纸
解题思路:一个超级源点,连接贴纸的种类,容量为1这个人所拥有的该种类的贴纸数量
将所有贴纸的种类连接到超级汇点,容量为1
在弄出N-1个点,代表另外的人,如果该贴纸的种类对方没有,那么连边,容量为1,因为只需要1张就够了(贴纸 –>人)
如果该贴纸对方有至少两张,那么连边,容量为这个人的该贴纸的数量-1(至少要保留一张,人–>贴纸)
然后跑最大流
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define N 1010
#define INF 0x3f3f3f3f
struct Edge{
int from, to, cap, flow;
Edge() {}
Edge(int from, int to, int cap, int flow) : from(from), to(to), cap(cap), flow(flow) {}
};
struct Dinic{
int n, m, s, t;
vector<Edge> edges;
vector<