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

一次就ac了!爽死了!呵呵呵!

Posted by chenxuan123456789 at 2012-09-11 15:21:14 on Problem 2239
#include <stdio.h>
#include <string.h>
#define len 310
int map[len][len];
int used[len],link[len];
int dfs(int a)
{
	int i;
	for(i=1;i<=len;i++)
	{
		if(!used[i]&&map[a][i])
		{
			used[i]=1;
			if(link[i]==-1||dfs(link[i]))
			{
				link[i]=a;
				return 1;
			}
		}
	}
	return 0;
}
int main()
{
	int n,m,i,a,b,sum;
	while(scanf("%d",&n)!=EOF)
	{
		memset(map,0,sizeof(map));
		memset(link,-1,sizeof(link));
		for(i=1;i<=n;i++)
		{
			scanf("%d",&m);
             map[i][0]=m;
			while(m--)
			{
				scanf("%d %d",&a,&b);
				map[i][12*a+b]=1;
			}
		}
		sum=0;
		for(i=1;i<=n;i++)
		{
			memset(used,0,sizeof(used));
			if(dfs(i))
				sum++;
		}
		printf("%d\n",sum);
	}
	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