Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我的本来TLE.改了之后死活WA,不知道哪里错了,谁帮我看下啊,谢谢了#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator