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 DieIng at 2008-10-16 18:30:37 on Problem 3281
In Reply To:WA,匹配怎么做的啊?大牛们~ Posted by:choupigwb at 2008-10-16 15:57:48
> #include <iostream>
> using namespace std;
> 
> const int N=111;
> 
> int n,f,d,Fcnt[N],Dcnt[N],F[N],D[N],link[N];
> bool s[N],g[N][N],v[N][N][N],use[N],canuse[N];
> 
> bool find(int a)
> {
> 	int i,j;
> 	for(i=1;i<=d;i++)
> 	{
> 		if(!s[i]&&g[a][i])
> 		{
> 			for(j=1;j<=n;j++)
> 			{
> 				if(v[a][i][j]&&canuse[j])
> 				{
> 					canuse[j]=false;
> 					s[i]=true;
> 					if(link[i]==0||find(link[i]))
> 					{
> 						link[i]=a;
> 						return true;
> 					}
> 				}
> 			}
> 		}
> 	}
> 	return false;
> }
> 
> int main()
> {
> 	int i,j,k;
> 	scanf("%d%d%d",&n,&f,&d);
> 	for(i=1;i<=n;i++)
> 	{
> 		scanf("%d%d",&Fcnt[i],&Dcnt[i]);
> 		for(j=1;j<=Fcnt[i];j++)
> 			scanf("%d",&F[j]);
> 		for(j=1;j<=Dcnt[i];j++)
> 			scanf("%d",&D[j]);
> 		for(j=1;j<=Fcnt[i];j++)
> 			for(k=1;k<=Dcnt[i];k++)
> 			{g[F[j]][D[k]]=true;v[F[j]][D[k]][i]=true;}
> 	}
> 	int ans=0;
> 	for(i=1;i<=f;i++)
> 	{
> 		memset(s,false,sizeof(s));
> 		memset(canuse,true,sizeof(canuse));
> 		if(find(i))ans++;
> 	}
> 	printf("%d\n",ans);
> 	return 1;
> }

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