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 galaxy at 2006-08-09 05:13:28 on Problem 1466
In Reply To:如何构图啊 Posted by:galaxy at 2006-08-09 04:55:21
int main()
{
	int n,m;
	int i,j,num,k;
	int hash[1000];
	int sign[1000];
	int n1,n2;
	int love[501][501];
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	while (scanf("%d",&n)!=EOF)
	{
	memset(hash,-1,sizeof(hash));
	memset(love,0,sizeof(love));
	//ma.Init(n,n);
	int n1=-1,n2=-1;
	for (i=0;i<n;i++)
	{
		scanf("%d: (%d) ",&num,&k);	
		if (hash[num]==-1)
			n1++;
		for (j=0;j<k;j++)
		{
			int v;
			scanf("%d",&v);
			if (hash[num]==-1)
			{
				if (hash[v]==-1) 
				{
					n2++;
					love[n1][n2]=1;
					hash[v]=n2;
				}else 
				  love[n1][hash[v]]=1;
			}
		}
	}
	ma.Init(n1+1,n2+1);
	for (i=0;i<=n1;i++)
		for (j=0;j<=n2;j++)
			if (love[i][j]==1)
				ma.AddEdge(i,j);
	printf("%d\n",n-ma.WorkMatch());
	}
	return 0;
}

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