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

help!!!!!!!!!!!!!!!!!!!!!!!

Posted by 1234554321 at 2005-04-23 22:02:01 on Problem 2419
#include<iostream.h>

int main()
{
	int t,p;
	cin>>p>>t;
	int i;
	int j;
	int a[100][100]={0};
	int b[100]={0};
	while(cin>>i>>j)
	{
		for(int q=0;q<b[i];q++)
		{
			if(a[i][q]==j)
				continue;
		}
		a[i][b[i]]=j;
		b[i]++;
	}
	for(int k=1;k<=p;k++)
	{
		if(a[k][0]==0) continue;
		for(int x=k+1;x<=p;x++)
		{
			if(a[x][0]==0) continue;
			int num=0;
			for(int y=0;y<t;y++)
			{
				if(a[k][y]==0) break;
				int count=0;
				for(int z=0;z<t;z++)
				{
					if(a[k][y]==a[x][z]) 
					{
						count=1;
						break;
					}
				}
				if(count==0) 
				{
					num=1;
					break;
				}
			}
			if(num==0)
				a[x][0]=0;
		}
	}
	int no=0;
	for(int s=1;s<=p;s++)
		if(a[s][0]!=0) no++;
	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