题目
思路
最大独立集=n-最小点覆盖=n-最大边匹配
代码
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef pair<int, int> PII;
const int N = 110;
int dx[8] = {-2, -1, 1, 2, 2, 1, -1, -2};
int dy[8] = {1, 2, 2, 1, -1, -2, -2, -1};
int g[N][N], st[N][N];
PII match[N][N];
int n, m, t;
bool find(PII u)
{
for(int i = 0; i < 8; i++)
{
int x = u.x + dx[i], y = u.y + dy[i];
if(x < 1 || y < 1 || x > n || y > m || g[x][y] || st[x][y]) continue;
st[x][y] = 1;
if(!match[x][y].x || find(match[x][y]))
{
match[x][y] = u;
return true;
}
}
return false;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> t;
for(int i = 1; i <= t; i++)
{
int a, b;
cin >> a >> b;
g[a][b] = 1;
}
int ans = 0;
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= m; j++)
{
if((i+j) % 2 || g[i][j]) continue;
memset(st, 0, sizeof st);
if(find({i, j})) ans++;
}
}
cout << m*n - t - ans;
}