POJ 1325 Machine Schedule

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.