http://acm.hdu.edu.cn/showproblem.php?pid=1150
Minimum point overwrite = maximum match
Template questions
1#include <iostream>2#include <stdio.h>3#include <math.h>4#include <string.h>5#include <stdlib.h>6 using namespacestd;7 Const intn= the;8 intA[n][n];9 intUse[n];Ten intMatch[n]; One intn,m,k; A - intDfsintu) - { the for(intI=0; i<m;i++) - { - if(a[u][i]==1&&!use[i])//determine if contact and match have been made - { +use[i]=1;//tag Matching - if(match[i]==-1|| DFS (Match[i]))//if not matched, match +{//if it matches, force the match and backtrack to the last matched AMatch[i]=u;//machine, make other matches, if not, this match fails at return 1; - } - } - } - return 0; - } in intbipartite () - { to intres=0; +memset (match,-1,sizeof(Match)); - for(intI=0; i<n;i++) the { *memset (use,0,sizeof(use)); $ if(Dfs (i))Panax Notoginsengres++; - } the returnRes; + } A intMain () the { + //freopen ("In.txt", "R", stdin); - while(~SCANF ("%d",&N)) $ { $ if(!N) - Break; - inth,p,q; theMemset (A,0,sizeof(a)); -scanf"%d%d",&m,&k);Wuyi for(intI=0; i<k;i++) the { -scanf"%d%d%d",&h,&p,&q); Wu if(p>0&&q>0) -a[p][q]=1; About } $ intt=bipartite (); -printf"%d\n", T); - } - return 0; A}
HDU1150 Machine Schedule