Analysis: First to find out the maximum number of matches, and then with a matching point of a single removal to see if the maximum match, can be the key point (very violent AH), but unexpectedly just 31ms************************************************* #include <stdio.h>
#include <string.h>
#include <algorithm>
usingnamespaceStd
ConstintMAXN = the;
BOOLG[MAXN][MAXN], USED[MAXN];
BOOLFind (intIintNintP[])
{
for(intj=1; j<=n; J + +)
{
if(G[i][j] && used[j] = =false)
{
USED[J] =true;
if(!p[j] | | Find (P[j], N, p))
{
P[J] = i;
returntrue;
}
}
}
returnfalse;
}
intXYL (intP[],intMintN
{
intAns =0;
for(intI=1; i<=m; i++)
{
memset (Used,false,sizeof(used));
if(Find (i, N, p) = =true)
ans++;
}
returnAns
}
intMain ()
{
intN, M, T, t=1;
while(SCANF ("%d%d%d", &m, &n, &t)! = EOF)
{
intI, u, v;
intp1[maxn]={0}, p2[maxn]={0};
memset (G,false,sizeof(G));
while(t--)
{
scanf"%d%d", &u, &v);
G[U][V] =true;
}
intMax = XYL (P1, M, N);
intimp=0;
for(i=1; i<=n; i++)
{
if(P1[i])
{
memset (P2,0,sizeof(p2));
g[P1[i]][i] =false;
if(XYL (P2, M, N) < Max)
imp++;
g[P1[i]][i] =true;
}
}
printf"Board%d has%d important blanks for%d chessmen.\n", t++, IMP, Max);
}
}
D-board game-HDU 1281 (binary image matching)