求重要的点。那就可以通过枚举来找;先做一次最大匹配,求出匹配数。然后逐一枚举这些点。如果匹配数改变,那就是重要点;
#include<stdio.h>
#include<string.h>
int map[][],n,m,vis[],match[];
int x[],y[];
int dfs(int u)
{
int i,j;
for(i=;i<=m;i++)
{
if(!vis[i]&&map[u][i])
{
vis[i]=;
if(match[i]==-||dfs(match[i]))
{
match[i]=u;
return ;
}
}
}
return ;
}
int main()
{
int i,j,k,ff=;
while(scanf("%d%d%d",&n,&m,&k)!=EOF)
{
memset(map,,sizeof(map));
for(i=;i<k;i++)
{
scanf("%d%d",&x[i],&y[i]);
map[x[i]][y[i]]=;
}
memset(match,-,sizeof(match));
int ans=;
for(i=;i<=n;i++)
{
memset(vis,,sizeof(vis));
if(dfs(i))
ans++;
}
int test=,flag;
int sum=;
for(i=;i<k;i++)
{
flag=map[x[i]][y[i]];
map[x[i]][y[i]]=;
test=;
memset(match,-,sizeof(match));
for(j=;j<=n;j++)
{
memset(vis,,sizeof(vis));
if(dfs(j))
test++;
}
if(test!=ans)
sum++;
map[x[i]][y[i]]=flag;
}
printf("Board %d have %d important blanks for %d chessmen.\n",++ff,sum,ans);
}
}