最大独立集 : 选出最多的点,使选出的点之间没有边
等价于 总点数 - 去掉最少的点,将所有的边破坏掉
等价于 总点数 - 最小点覆盖
等价于 总点数 - 最大匹配数
#include<bits/stdc++.h>
#define LL long long
#define x first
#define y second
#define de(x) cout<<#x<<" = "<<x<<" "
#define deg(x) cout<<#x<<" = "<<x<<endl
using namespace std;
const int N=110,M=110;
typedef pair<int,int> PII;
int n,m;
int g[N][N],st[N][N];
PII match[N][N];
int dx[]={-1,1,-2,2,-1,1,-2,2};
int dy[]={2,2,1,1,-2,-2,-1,-1};
bool find(int x,int y)
{
for(int i=0;i<8;i++)
{
int a=x+dx[i],b=y+dy[i];
if(a<=0||b<=0||a>n||b>m||st[a][b]||g[a][b])continue;
st[a][b]=1;
PII t=match[a][b];
if(t.x==-1||find(t.x,t.y))
{
match[a][b]={x,y};
return 1;
}
}
return 0;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
int t;
cin>>t;
for(int i=0;i<t;i++)
{
int a,b;
cin>>a>>b;
g[a][b]=1;
}
int res=0;
memset(match,-1,sizeof match);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
if((i+j)%2==0||g[i][j])continue;
memset(st,0,sizeof st);
if(find(i,j))res++;
}
cout<<n*m-t-res<<endl;
return 0;
}