题目链接
https://www.luogu.org/problemnew/show/P3355
骑士共存问题
我们首先将这个网格图黑白染色,我们把会互相攻击的点黑向白连边,显然同颜色的点不会互相攻击,所以得到一张二分图,我们去一个点表示我将骑士从这个点上拿走,最后使得每条边至少有一端被拿走,这刚好就是二分图最小顶点覆盖问题,然后我们知道二分图最小顶点覆盖=二分图最大匹配,所以网络流跑个二分图最大匹配就行了,然后有障碍的点不要连边就行。最后答案为n*n-m-maxflow
#include<cstdio>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<iostream>
#define LL long long
#define INF (2139062143)
#define N (205)
using namespace std;
int n,m,S,T,all,tot,x,y,ans;
int map[N][N],a[N*N*8],f[N*N*8],nxt[N*N*8],cur[N*N],head[N*N],h[N*N],co[N*N];
template <typename T> void read(T&t) {
t=0;
bool fl=true;
char p=getchar();
while (!isdigit(p)) {
if (p=='-') fl=false;
p=getchar();
}
do {
(t