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 Selfind at 2007-11-03 13:48:17
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	int T;
	string str[4000],a,b[4000];
	
	while(cin>>T&&T!=0)
	{
     int n=T;                 
    int i,j,k;
	int g=0;
	while(T-->0)
	{
	cin>>str[T];//数据录入
	}

	//模块内输出结果
	
	
    int res=str[0].size ();
	bool suc=false;
	bool suc2=false;
	for(;res>0;res--)
	{
                   
		for(k=0;k+res<=str[0].size();k++)
		{
		a=str[0].substr(k,res);
		suc=true;
		for(j=1;j<n;j++)
		{
 	      if(str[j].find(a)==-1)
          {
   	       suc=false;
   	       break;
   	      }            	     
		}
                      
		if(suc)
		{  
		suc2=true;  
		b[g]=a;
		g++;
		}
		}
	if(suc2) break;	
	}
	if(suc2)
	{
           string result;
           int e,f;
           for(e=0;e<g;e++)
           {
		   for(f=e;f<g;f++)
		   {
		   if(b[e]<b[f])
		   {
		   result=b[e];
		   }
		   else result=b[f];
		   }
           }
		   cout<<result<<endl;
	
	}
	else cout<<"IDENTITY LOST\n";
	
	}
	
	
	
    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