HDU 20,632-point map matching

Source: Internet
Author: User

Test instructions: Some women and some men have a good opinion, have a good feeling can ride a roller coaster, ask the most can compose how many

HDU 11 page on the few algorithm problems, two-figure matching problem, Hungarian algorithm, for each man, see and he has a good sister there is no pairing, no pairing can be successful pairing, if it has been paired, look at that sister matched man can find a sister who is not paired, If you can break up the current pairing recombination pairing, otherwise it will not be dismantled; if all the good girls still fail to match, the man is doomed to be lonely for a lifetime.

1#include <stdio.h>2#include <string.h>3 intnow,head[1001],next[1001],point[1001],visit[1001],match[1001];4 5 voidAddintXinty) {6next[++now]=Head[x];7head[x]=Now ;8point[now]=y;9 }Ten  One intDfsintk) A { -      for(intI=head[k];i;i=next[i])if(!Visit[point[i]]) { -         intp=Point[i]; thevisit[p]=1; -         if(match[p]==-1||DFS (match[p])) { -match[p]=K; -             return 1; +         } -     } +     return 0; A } at  - intMain () { -     intK,m,n; -      while(SCANF ("%d", &k)!=eof&&k!=0){ -scanf"%d%d",&m,&N); -memset (match,-1,sizeof(Match)); inMemset (Head,0,sizeof(head)); -now=0; to         inti,ans=0; +          for(i=1; i<=k;i++){ -             intb; thescanf"%d%d",&a,&b); * Add (A, b); $         }Panax Notoginseng          for(i=1; i<=m;i++){ -memset (Visit,0,sizeof(visit)); the             if(Dfs (i) = =1) ans++; +         } Aprintf"%d\n", ans); the     } +     return 0; -}
View Code

HDU 20,632-point map matching

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.