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

g[100][300]; WA

Posted by dreamseeker at 2007-01-16 14:39:40 on Problem 1469
In Reply To:-_- 为什么动态开辟数组 RE -_- Posted by:dreamseeker at 2007-01-16 14:34:13
#include"iostream"
using namespace std;
bool g[100][300];
int n,m;
int mat[100],tmat[300];
int find(int i)
{
	int v,j;
	for (j=0;j<m;j++)
		if (g[i][j]&&tmat[j]==0)
		{
			tmat[j]=1;v=mat[j];
			mat[j]=i;
			if (v==-1||find(v)) return 1;
			mat[j]=v;
		}
		return 0;
}
int match()
{
	int i,k=0;
	memset(mat,-1,sizeof(mat));
	for (i=0;i<n;i++)
	{
		memset(tmat,0,sizeof(tmat));
		k+=find(i);
	}
	return k;
}
int main()
{
	int i,j,t,Case,p;
	cin>>Case;
	while(Case--)
	{
		cin>>n>>m;
        for (i=0;i<n;i++)
			for (j=0;j<m;j++)
				g[i][j]=false;
			for (i=0;i<n;i++)
			{
				scanf("%d",&t);
				while(t--)
				{
					scanf("%d",&p);
					g[i][p-1]=true;
				}
			}  
			if(match()==n)
				printf("YES\n");
			else
				printf("NO\n");
	}	
	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