Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

用匈牙利算法求二分图的覆盖数

Posted by semonteer at 2005-09-18 22:24:39 on Problem 2594
In Reply To:是新手,不知哪位肯指导一下,我可能把问题想简单了,但又不知道错在哪里,详见以下源代码。。。 Posted by:flyll at 2005-09-18 21:49:35
> #include "stdio.h"
>   #define N 500
>   #define M 5000
>   main()
>   {
>     int m,n,a,b,i,q[N],k;
>     scanf("%d %d",&n,&m);
>     while(n!=0||m!=0)
>     {
>      for(i=0;i<n;i++)
>      q[i]=i+1;
>      k=0;
>      for(i=0;i<m;i++)
>      {
>       scanf("%d %d",&a,&b);
>       if(q[a]!=0&&q[b]!=0)
>       {k++;q[a]=0;q[b]=0;}
>       if(q[a]==0&&q[b]!=0)
>       q[b]=0;
>       if(q[a]!=0&&q[b]==0)
>       q[a]=0;
>      }
>      for(i=0;i<n;i++)
>      if(q[i]!=0)
>      k++;
>      printf("%d\n",k);
>      scanf("%d %d",&n,&m);
>     }
>   }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator