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 00448087 at 2005-07-30 21:52:32 on Problem 2419
#include<iostream.h>
int fn( int**, int, int);
void print(int**,int,int);
void main()
{
	int p,t;
	cin>>p>>t;
	//int *a=new int[p];//总的树木;
	int **arr=new int *[p];
	for(int i=0;i<p;i++)
		arr[i]=new int [102];
	int j;
	for(i=0;i<p;i++)
		for(j=0;j<102;j++)
			arr[i][j]=0;

	int pp,tt,z=0;
	while(cin>>pp>>tt)
	{
		z++;
		arr[pp-1][tt-1]=1;
		arr[pp-1][t+1]=1;
		
	}
	  //print(arr,p,t);
	if(z!=0){
	int total=fn(arr,p,t);
	// print(arr,p,t);
	cout<<total<<endl;
	}
	else cout<<0<<endl;
}
int fn(int **arr,int p,int t)
{
	int pp=1,i=0,j,k,q=0;
	for(i=0;i<p;i++)
		if(arr[i][t+1]==1)
		for(j=i+1;j<p;j++) 
			if(arr[j][t]==0&&arr[j][t+1]==1)
			{
				for(k=0;k<t;k++){
				 
					if(arr[i][k]!=arr[j][k])
					{
						pp++;
					    //cout<<"pp="<<pp<<" i="<<i<<" j="<<j<<endl;
						break;
					}
					else q++;
				}

					if(q==t)
					{arr[j][t]=1;}//cout<<"arr["<<j<<"]"<<endl;}
					q=0;
			}
		 
				 
	return pp ;
}
void print(int **arr,int p,int t)
{
	for(int i=0;i<p;i++)
	{
		for(int j=0;j<t+2;j++)
			cout<<arr[i][j]<<' ';
		cout<<endl;		 
	}
}

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