洛谷 P2774 方格取数问题 最小割 -最大流
先染色成二分图
最大取和 = 最大和-最小舍弃和 = 最小割 二分图 : 最大点独立集 = 总权和 - 最小点覆盖集(最小割)
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 20000 + 10;
const int maxm = 1000000 + 10;
int n,m,k;
int l[maxn];//记录层数
int h[maxn];//链式前向星
int cur[maxn];
int tot = 0;
struct edge
{
int to;
int c;
int next;
edge(int x = 0, int y = 0, int z = 0) : to(x), c(y), next(z) {}
}es[maxm*2];//记录边 注意是2倍
void add_edge(int u, int v, int c)
{
es[to