Deepened my understanding of the minimum point coverage.
Connect the two machines of each task, the problem is to select the least points to cover all the lines, that is, the minimum point coverage
1#include <iostream>2#include <cstring>3#include <cstdio>4#include <vector>5 using namespacestd;6 Const intmaxn= the;7vector<int>map[ the];8 intLINK[MAXN],VIS[MAXN];9 intn,m,k;Ten BOOLDfsintt) One { A intI,x,size=map[t].size (); - for(i=0; i<size;i++) - { thex=Map[t][i]; - if(!Vis[x]) - { -vis[x]=1; + if(link[x]==-1||DFS (link[x])) - { +link[x]=T; A return 1; at } - } - } - return 0; - } - intMain () in { - inti,a,b,c; to while(~SCANF ("%d", &n) &&N) + { -scanf"%d%d",&m,&k); the for(i=1; i<=n;i++) map[i].clear (); * for(i=0; i<k;i++) $ {Panax Notoginsengscanf"%d%d%d",&a,&b,&c); - if(b&&c) Map[b].push_back (c); the } +memset (link,-1,sizeof(link)); A intans=0; the for(i=1; i<=n;i++) + { -memset (Vis,0,sizeof(Vis)); $ if(Dfs (i)) ans++; $ } -printf"%d\n", ans); - } the}
HDU 1150-machine Schedule