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 struggle6688 at 2015-07-15 09:02:52 on Problem 1469 and last updated at 2015-07-15 09:03:39
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
bool link[305][500],used[3000],girl[3000];
int n;
bool find(int x)
{
	for(int i=1;i<=n;i++)
	{
		if(link[x][i]&&used[i]==0)
		{
			used[i]=1;
			if(girl[i]==0||find(girl[i]))
			{
				girl[i]=x;
				return true;
			}
		}
	}
	return false;
}
int main()
{
	int t,p,num,temp;
	cin >> t;
	while(t--)
	{
		scanf("%d%d",&p,&n);
		memset(link,0,sizeof(link));
		memset(girl,0,sizeof(girl));
		for(int i=1;i<=p;i++)
		{
			scanf("%d",&num);
			for(int j=1;j<=num;j++)
			{
				scanf("%d",&temp);
				link[i][temp]=1;
			}
		}
		int k;
		for(k=1;k<=p;k++)
		{
			memset(used,0,sizeof(used)); 
			if(!find(k))
				break;
		}
		if(k>p)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	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