Poj 1325 Machine Schedule-minimum vertex Overwrite

Source: Internet
Author: User
/* Question: machine A has n (0 ~ N-1) mode. Machine B has m (0 ~ M-1) mode, there are K tasks to be done first. You can use the AI mode of machine A or the Bi mode of machine B to do tasks without sequence. Restart the tasks in order of mode change, start two machines in the Mode 0 ask at least the restart is required several times. In the mode where the minimum vertex of the Bipartite Graph overwrites A, X Set B. In the mode where the y set calculates the minimum vertex overwrite task by task creation edge. minimum number of restarts, that is to say, it should work in at least several modes (except for the 0 mode) as long as any vertex of the edge is selected, so the minimum vertex overwrites These vertices and captures all edges, set to complete all tasks. The mode is the pattern minimum point covered by the store = maximum matching of the Bipartite Graph */# include <stdio. h ># include <vector> using namespace STD; int n, m, K; vector <int> V [201]; int vis [201]; int match [201]; int DFS (int I) {for (Int J = 0; j <V [I]. size (); ++ J) {If (! Vis [V [I] [J] + N]) // + N indicates the adjustment number {vis [V [I] [J] + N] = 1; if (Match [V [I] [J] + N] =-1 | DFS (Match [V [I] [J] + N]) {match [V [I] [J] + N] = I; return 1 ;}}return 0 ;}int main () {int I, A, B, C; while (scanf ("% d", & N), n) {scanf ("% d", & M, & K); for (I = 0; I <= m + n; ++ I) V [I]. clear (); for (I = 1; I <= K; ++ I) {scanf ("% d", & A, & B, & C); If (B & C) V [B]. push_back (c); // you only need to point from X set to y set. When DFS () is completed, it is only from X to Y} A = 0; /// match part of memset (match,-1, sizeof (MATCH); for (I = 1; I <= N; I ++) {memset (VIS, 0, sizeof (VIS); If (DFS (I) A ++;} // printf ("% d \ n", );} return 0 ;}

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.