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 tq at 2005-08-29 22:54:12 on Problem 2594
In Reply To:“匹配”是什么意思? Posted by:slwgu at 2005-08-29 22:14:48
> #include <iostream.h>
> 
> bool c[500][500];
> bool v[500];
> long n,m;
> 
> int main()
> {
> 	long i,j,k;
> 	long x,y;
> 	long sum;
> 	bool ch;
> 	while (cin>>n>>m)
> 	{
> 		if ((n+m)==0) break;
> 		for (i=0;i<n;i++)
> 		{
> 			v[i]=true;
> 			for (j=0;j<n;j++)
> 				c[i][j]=false;
> 		}
> 
> 		for (i=0;i<m;i++)
> 		{
> 			cin>>x>>y;
> 			x--;y--;
> 			c[x][y]=true;
> 		}
> 		do
> 		{
> 			ch=false;
> 			for (i=0;i<n;i++)
> 				for (j=0;j<n;j++)
> 					if (c[j][i])
> 						for (k=0;k<n;k++)
> 							if (!c[j][k] && c[i][k])
> 								ch=c[j][k]=true;
> 		}while(ch);
> 
> 		sum=0;
> 		for (i=0;i<n;i++)
> 		{
> 			for (j=0;j<n;j++)
> 				if (c[i][j] && v[j])
> 				{
> 					sum++;
> 					v[j]=false;
> 					break;
> 				}
> 		}
> 		cout<<n-sum<<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