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

为什么老是wa,请帮忙

Posted by 00448144 at 2005-04-28 21:49:53 on Problem 2419
#include<iostream.h>
int isEqual(int *, int *, int);
void main()
{
	int p,t,person,tree,result;
	int a[100][100];
	for(int i=0;i<100;i++)
		for(int j=0;j<100;j++)
			a[i][j]=0;
    cin>>p>>t;
	result=p;
	while(cin>>person>>tree)
	{	
        a[person-1][tree-1]=1;
	}
   	for(i=0; i<100; i++)
		for(int j=i+1; j<100; j++)
		{
			if(isEqual(a[i],a[j],100))
			{
			    for(int m=0; m<100; m++)
			    	a[j][m]=0;
			}
		}
	for(i=0;i<p;i++)
	{
		for(int j=0;j<100;j++)
		{
			if(a[i][j]!=0)
			{
			   break;
			}
		}
		if(j==100)
			result--;
	} 
	cout<<result<<endl;
}

int isEqual(int *a,int *b,int n)
{
	for(int i=0;i<n;i++)
		if(a[i]!=b[i])
			return 0;
	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