Poj1325-Machine Schedule

Source: Internet
Author: User


Want to see more problem-solving reports:Http://blog.csdn.net/wangjian8006/article/details/7870410

Reprinted please indicate the source:Http://blog.csdn.net/wangjian8006

 

There are two machines a and B, machine A has n modes, machine B has m modes, and two machines are initially in 0 mode.

Then there are K jobs. Each job has three parameters I, A, and B.
I indicates the job number. A and B indicate that the I job is completed either in the mode of machine A or in the B mode of machine B.
How many times can the two machines perform at least one transformation?

Solution: The minimum point coverage of a Binary Graph
Create a bipartite graph with n vertices on the left and N vertices on the left.
The right side represents the machine B, M points, and m modes.
Now, for each job, I, A, and B, point A on the left is directed to point B on the right.
In this way, if we want to finish all the jobs, do we need to find the smallest vertex to overwrite all the edges?
Then, the minimum vertex overwrite is equal to the maximum match.
If you are not clear, draw a sample.

 

/* Memory 212 ktime 32 Ms */# include <iostream> using namespace STD; # define maxv 110int n, m, K; int map [maxv] [maxv]; int link [maxv], use [maxv]; int DFS (int x) {int I, j; for (I = 1; I <= m; I ++) if (Map [x] [I] &! Use [I]) {J = link [I]; use [I] = 1; Link [I] = X; if (j =-1 | DFS (j) return true; Link [I] = J;} return false;} int Hungary () {int num = 0; int I, j; memset (link,-1, sizeof (Link); for (I = 1; I <= N; I ++) {for (j = 1; j <= m; j ++) use [J] = 0; If (DFS (I) num ++;} return num ;} int main () {int, b, C, I; while (scanf ("% d", & N) {scanf ("% d", & M, & K ); memset (MAP, 0, sizeof (MAP); for (I = 0; I <K; I ++) {scanf ("% d ", & A, & B, & C); map [B] [C] = 1;} printf ("% d \ n", Hungary ();} 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.