Main topic:
There are two machines, each of the two machines have n,m mode, there are k tasks, each task can be completed by a mode of two machines, each switching mode will need to restart the machine, ask at least reboot several times the machine can complete all tasks (start both machines are mode 0)
Ideas:
Hungary minimum Point coverage
Because there are only two kinds of machines, you can turn each mode into a point, and all points have only two colors, which is a two-part graph.
And then the task as an edge, connected to two different modes
Then go directly to Hungary and ask for the minimum point coverage AC
#include <iostream>#include<cstdio>#include<algorithm>#include<cmath>#include<cstring>using namespacestd;intn,m,k,a,b,c,link[ About];BOOLmap[ About][ About],vis[ About];BOOLFindintx) { for(intI=0; i<m;i++) { if(map[x][i]&&!Vis[i]) {Vis[i]=true; if(link[i]==-1|| Find (Link[i])) {link[i]=x;return true;} } } return false;}intMain () { while(SCANF ("%d", &n) &&n!=0) {scanf ("%d%d",&m,&k); intans=0; memset (Link,0xFF,sizeof(link)); memset (Map,false,sizeof(map)); for(intI=0; i<k;i++) {scanf ("%d%d%d", &a,&b,&c);if(b!=0&&c!=0) map[b][c]=true;} for(intI=0; i<n;i++) {memset (Vis,false,sizeof(VIS)); if(Find (i)) ans++; } printf ("%d\n", ans); }}
View Code
POJ 1325 Machine Schedule