Title: With the least starting point, take all the edges
Analysis: For the maximum match, half of the points can be connected to all edges. Can prove that if there is a match in the maximum matching point is not connected with it, then join this edge, and will not break the matching nature and make the largest match, and the hypothesis contradiction, so the proof is established.
/************************************************author:D arktongcreated time:2016/7/31 11:28:07File Name: poj_1325.cpp*************************************************///#include <bits/stdc++.h>#include <cstdio>#include<cstring>using namespacestd;Const intMAXN = -+Ten;intW[MAXN][MAXN], N, m;intLEFT[MAXN];BOOLUSED[MAXN];BOOLMatchinti) { for(intj=1; j<=n;++j)if(w[j][i]&&!Used[j]) {Used[j]=true; if(! left[j]| |match (Left[j])) {Left[j]=i; return true; } } return false;}//returns the maximum number of matchesintHungary () {intres=0; Memset (left,0,sizeof(left)); for(intI=1; i<=m;++i) {memset (used,0,sizeof(used)); if(Match (i)) res++; } returnRes;}intMain () {intT, cas=1; intK; while(SCANF ("%d", &n) = =1&&N) {scanf ("%d%d", &m, &k); Memset (W,0,sizeof(w)); intA, B, C; for(intI=0; i<k;++i) {scanf ("%d%d%d", &a, &b, &c); W[B][C]=1; } printf ("%d\n", Hungary ()); } return 0;}
poj_1325 machine Schedule-Maximum matching properties topic