Test instructions: In a n*n matrix, there are m points, each elimination of a row or a column of points, the minimum number of operations;
Idea: The x-axis and the y-axis as two different sets, each row or column as a point, each given point as an edge, so that the two-part map is built;
Eliminate all points, the matrix is completely covered, so as to the minimum point coverage problem;
Minimum cover number = maximum number of matches, so the maximum number of matches is required;
#include <cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespacestd;intT,n,m,shu;intmm[505][505];intvis[500010],link[500010];intDfsintx) { inti,j,k; for(i=1; i<=n;i++) { if(!vis[i]&&Mm[x][i]) {Vis[i]=1; if(link[i]==-1||DFS (Link[i])) {Link[i]=x; return 1; } } } return 0;}intHungary () {inti,j,k; intsum=0; memset (Link,-1,sizeof(link)); for(i=1; i<=n;i++) {memset (Vis,0,sizeof(VIS)); if(Dfs (i)) sum++; } returnsum;}intMain () {inti,j,k,u,v; while(SCANF ("%d%d", &n,&m)! =EOF) {memset (mm,0,sizeof(mm)); for(i=0; i<m;i++) {scanf ("%d%d",&u,&v); MM[U][V]=1; } printf ("%d\n", Hungary ()); } return 0;}
POJ 3041 Asteroids (minimum point coverage)