Analysis: The problem can be used to match the x-coordinate of the y-coordinate, the match is a successful one can put a piece of points, the last to find the best binary matching is the maximum number of pieces can be put. The maximum match of the binary graph is using the Hungarian algorithm. After the deletion of an edge to determine whether a point is a key point, if the deletion, the maximum number of matches is not the same, otherwise, by deleting each point to test, you can finally calculate the number of key points.
#include <iostream>using namespace std; #define N 102int map[n][n]; Record connections x and Y side bool Vis[n]; Record if the node in Y has used int link[n]; The node that records the x currently connected to the y node int findmatch (int u,int m)//Discovery Match {int i;for (i=1;i<=m;i++) if (map[u][i]==1 &&!vis[i]) {vis[ I]=true;if (Link[i]==-1 | | Findmatch (link[i],m))//findmatch (link[i],m) matches {Link[i]=u;return 1 before re-matching} return 0;} void Keypointandmatchcount (int& keypoint,int &match,int n,int m) {int I,j,ans,k;match=0;memset (link,-1,sizeof (link)); Find the maximum match for (i=1;i<=n;i++)//with X to match Y{memset (vis,false,sizeof (Vis)); Match+=findmatch (i,m);} Keypoint=0;for (i=1;i<=n;i++)//By removing key edge for (j=1;j<=m;j++) {ans=0;if (map[i][j]==1) {memset (link,-1,sizeof (li NK)); Map[i][j]=0;for (k=1;k<=n;k++) {memset (vis,false,sizeof (VIS)); Ans+=findmatch (k,m);} Map[i][j]=1;if (Ans!=match)//Match not equal to a key point keypoint++;}}} int main () {int n,m,k,x,y;int t,keypoint,match,i; T=0;while (scanf ("%d%d", &n,&m,&k) ==3) {memset (map,0,sizeof (map)); for (i=0;i<k;i++) {scanf ("%d%d", &x,&y); map[x][y]=1;} Keypointandmatchcount (keypoint,match,n,m);p rintf ("Board%d has%d important blanks for%d chessmen.\n", ++t,keypoint, Match);} return 0;}
HDU ACM 1281 board Game--binary graph Max match (Hungarian algorithm practice)