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 huguang123 at 2009-02-27 13:20:24 on Problem 2001
#include <iostream>
using namespace std;
int main()
{
 char a[2000][44];
 char b[2000][44];
 int ji[1000]={0};
 int many=0;	
 while (gets(a[many])!=NULL){
  many+=1;
  //printf("%d\n",many); 
// getchar(); 
}
//system("pause");
 for (int i=0;i<many;i++)
	{	
	ji[i]=0;	
   	bool can;
   	can=false;
   while ((can==false)&&(ji[i]<strlen(a[i])))
    {
	 ji[i]+=1;
	 strncpy(b[i],a[i]+0,ji[i]);
	// printf("%s\n",b[i]);
	 //system("pause");
	 can=true;
	 for (int j=0;j<many;j++)	
	  if (j!=i)
	   {
		bool neng;
		neng=false;
		for (int yi=0;yi<strlen(b[i]);yi++)	
		 if (b[i][yi]!=a[j][yi]) neng=true;	
		if (neng==false) can=false;	
			}	
		}
	 printf("%s %s\n",a[i],b[i]);	
	}	
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