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

Re:构图犯了很白痴的错。。。不过好慢啊!!请教匹配是怎么做的呢??

Posted by 20053565 at 2007-07-22 03:51:03 on Problem 3281
In Reply To:构图犯了很白痴的错。。。不过好慢啊!!请教匹配是怎么做的呢?? Posted by:wzydeath at 2007-07-22 01:10:18
我的匹配 不过WA了
#include <stdio.h>
#include <string.h>

int n, f, d;
int map1[101][101], map2[101][101];
int b[101], link[101];
int B[101], Link[101];

int Find(int v)
{
	int i;

	for(i = 1; i <= d; i++)
	{
		if(map2[v][i]&&!B[i])
		{
			B[i] = 1;
			if(Link[i]==0||Find(Link[i]))
			{
				Link[i] = v;
				return 1;
			}
		}
	}
	return 0;
}

int find(int v)
{
	int i;

	for(i = 1; i <= n; i++)
	{
		if(map1[v][i]&&!b[i])
		{
			b[i] = 1;
			if(link[i]==0)
			{
				memset(B,0,sizeof(B));
				if(Find(i))
				{
					link[i] = v;
					return 1;
				}
			}
			else
				if(find(link[i]))
				{
					link[i] = v;
					return 1;
				}
		}
	}
	return 0;
}

int main()
{
	int i, j, t;
	int fi, di, ans = 0;

	scanf("%d%d%d",&n,&f,&d);
	memset(map1,0,sizeof(map1));
	memset(map2,0,sizeof(map2));
	for(i = 0; i < n; i++)
	{
		scanf("%d%d",&fi,&di);
		for(j = 0; j < fi; j++)
		{
			scanf("%d",&t);
			map1[t][i+1] = 1;
		}
		for(j = 0; j < di; j++)
		{
			scanf("%d",&t);
			map2[i+1][t] = 1;
		}
	}
	memset(link,0,sizeof(link));
	memset(Link,0,sizeof(Link));
	for(i = 1; i <= f; i++)
	{
		memset(b,0,sizeof(b));
		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