https://www.luogu.org/problemnew/show/P2770
建图方法: s s s到 1 1 1容量为2,费用为0, n ′ n' n′到 t t t容量为2,费用为0, 1 − > 1 ′ 和 n − > n ′ 1->1'和n->n' 1−>1′和n−>n′容量为2,费用为-1,其余 x − > x ′ x->x' x−>x′容量为1,费用为-1,再连接航线即可。
#include<bits/stdc++.h>
using namespace std;
const int maxn=100*2+100;
const int INF=0x3f3f3f3f;
typedef long long ll;
struct Edge{
int from,to,cap,flow,cost;
};
struct MCMF{
int n,m,s,t;
vector<Edge> edges;
vector<int> G[maxn];
int inq[maxn]