# RQNOJ141 looking for Representative yuan

Source: Internet
Author: User

Test Instructions: There are n elective courses, M with classmates, now tell you the members of each course, to choose a representative from each of the members of the course, a classmate can only represent an elective course, the maximum number of delegates. key: The Hungarian algorithm, the core algorithmCODE:
`/*Author:JDDPROG:rqnoj140 looking for representative meta date:2015.9.28*/#include<cstdio>#include<cstring>#defineREP (i, S, N) for (int i = s; i <= n; i + +)#defineRep_ (i, S, N) for (int i = n; i >= s; i-)#defineMax_n 205using namespacestd;intN, M, G[max_n], map[max_n][max_n];BOOLUsed[max_n];voidinit () {scanf ("%d%d", &n, &m); memset (Map,0,sizeof(map)); REP (i,1, N) {        intX scanf"%d", &x);  while(X! =0) Map[i][x] =1, scanf ("%d", &x); }    }BOOLFindintx) {REP (i,1, M) {        if(!used[i] &&Map[x][i]) {Used[i]=1; if(! G[i] | |find (G[i])) {G[i]=x; return 1; }        }    }    return 0;}voiddoit () {memset (G,0,sizeof(G)); intAns =0; REP (i,1, N) {memset (used,0,sizeof(used)); if(Find (i)) ans + +; } printf ("%d\n", ans);}intMain () {init ();    Doit (); return 0;}`

RQNOJ141 looking for Representative yuan

Related Keywords:

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.