POJ-1325 Machine Schedule The minimum point coverage of the binary diagram

Source: Internet
Author: User

The main topic: There are two machines, a machine has n mode of operation, B machine has m mode of operation, just started two machines are 0 mode. If you want to switch mode, the machine must be restarted.
There are k tasks, each task can be handed to the a machine I mode or B machine's J mode complete, ask how many times to restart the machine to complete the task

Problem-solving ideas: Two machine points are divided into two point sets. The relationship between point sets is a task. You want to finish all the tasks. It is necessary to cover all the edges, so the minimum point is covered.


Here's a point to note. Assuming that all tasks have a 0, then the machine does not have to restart, the number of restarts is 0 (since the beginning is 0)

#include <cstdio>#include <vector>#include <cstring>using namespace STD;Const intN = the;intN, M, K;intVis[n], link[n];BOOLFlag vector<int>G[n];voidInit () { for(inti =1; I < n; i++) g[i].clear ();intX, y, Z; for(inti =0; I < K; i++) {scanf("%d%d%d", &x, &y, &z);if(Y * z = =0)Continue;    G[y].push_back (z); }memset(Link,-1,sizeof(link));}BOOLDfsintu) { for(inti =0; I < g[u].size (); i++) {intv = g[u][i];if(Vis[v])Continue; VIS[V] =1;if(Link[v] = =-1|| DFS (Link[v])) {Link[v] = u;return true; }    }return false;}voidHungary () {intAns =0; for(inti =1; I < n; i++) {memset(Vis,0,sizeof(VIS));if(Dfs (i)) ans++; }printf("%d\n", ans);}intMain () { while(scanf("%d", &n)! = EOF && N) {scanf("%d%d", &m, &k);        Init ();    Hungary (); }return 0;}

POJ-1325 Machine Schedule The minimum point coverage of the binary diagram

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.