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

Re:我的本来TLE.改了之后死活WA,不知道哪里错了,谁帮我看下啊,谢谢了

Posted by tibelf at 2007-11-03 14:44:57 on Problem 3450
In Reply To:我的本来TLE.改了之后死活WA,不知道哪里错了,谁帮我看下啊,谢谢了 Posted by:tibelf at 2007-11-03 14:44:11
> #include <iostream>
> #include <string>
> using namespace std ;
> 
> int main(){
> 	int n ;
> 	while( cin >> n )
> 	{
> 		if( n == 0 )
> 			break ;
> 		int i , j , k ;
> 		string a[4001] , c ;
> 		for( i = 0 ; i < n ; i ++ )
> 			cin >> a[i] ;
> 		int len = a[0].size () ;
> 		bool find = false ;
> 		for( i = 0 ; i < len ; i ++ )
> 		{
> 			if( i == 0 )
> 				j = i + 1 ;
> 			else
> 				j = i ;
> 			for( ; j < len ; j ++ )
> 			{
> 				string b( a[0] , i , j ) ;
> 				bool flag = false ;
> 				for( k = 1 ; k < n ; k ++ )
> 				{
> 					int loc = a[k].find ( b , 0 ) ;
> 					if( loc == string ::npos )
> 					{
> 						flag = true ;
> 					}
> 				}
> 				if( flag )
> 					break ;
> 				if( !flag && b.size () > c.size () )
> 				{
> 					c = b ;
> 					find = true ;
> 				}
> 				if( b.size () == c.size () && b < c )
> 				{
> 					c = b ;
> 				}
> 
> 			}
> 		}
> 		if( find )
> 			cout << c << endl ;
> 		else
> 			cout << "IDENTITY LOST" << 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