Ein_Niemand @ 2019-01-24 13:18:21
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=40005;
#define rg register int
#define V inline void
#define I inline int
#define db double
#define F1(i,a,b) for(rg i=a;i<=b;++i)
#define F3(i,a,b,c) for(rg i=a;i<=b;i+=c)
#define ed putchar('\n')
#define bl putchar(' ')
template<typename TP>V read(TP &x)
{
TP f=1;x=0;register char c=getchar();
for(;c>'9'||c<'0';c=getchar()) if(c=='-') f=-1;
for(;c>='0'&&c<='9';c=getchar()) x=(x<<3)+(x<<1)+(c^48);
x*=f;
}
template<typename TP>V print(TP x)
{
if(x<0) x=-x,putchar('-');
if(x>9) print(x/10);
putchar(x%10+'0');
}
int dx[]={-2,-2,-1,-1,1,1,2,2};
int dy[]={1,-1,2,-2,2,-2,1,-1};
struct node{
int v,nxt;
}e[N<<2];
int h[N],tot,ans,match[N],vis[N],timer,cnt;
int n,m,x,y,l[205][205];
V add(rg u,rg v)
{
e[++tot].v=v;
e[tot].nxt=h[u];
h[u]=tot;
}
inline bool dfs(rg x)
{
if(vis[x]==timer) return false;
vis[x]=timer;
for(rg i=h[x];i;i=e[i].nxt)
{
rg v=e[i].v;
if(!match[v]||dfs(match[v])) {match[v]=x;return true;}
}
return false;
}
int main()
{
read(n),read(m);
F1(i,1,n)
F1(j,1,n) l[i][j]=++cnt;
F1(i,1,m) read(x),read(y),l[x][y]=0;
F1(i,1,n)
F3(j,(i&1)?1:2,n,2)
if(l[i][j])
F1(k,0,7)
{
int nx=i+dx[k],ny=j+dy[k];
if(nx&&ny&&nx<=n&&ny<=n&&l[nx][ny]) add(l[i][j],l[nx][ny]);
}
F1(i,1,n)
F3(j,(i&1)?1:2,n,2)
if(l[i][j])
{
++timer;
if(dfs(l[i][j])) ++ans;
}
print(cnt-m-ans);
return 0;
}
by TRZ_2007 @ 2019-01-24 13:22:31
tips:鲁迅:这不是我说的
by 马峰 @ 2019-01-24 13:23:57
那就。。。跑网络流?
by Ein_Niemand @ 2019-01-24 13:32:43
@马峰 我还没学