Pku 1056 IMMEDIATE DECODABILITY

Pku 1056 IMMEDIATE DECODABILITY
#include  < string >
#include 
< vector >
#include 
< algorithm >
#include 
< iostream >

using   namespace  std;

int  main()
{
    
string  str;
    
int     num =   1 ;
    
    
while ( cin  >>  str )
    
{
        vector
< string >   d;
        
if ( str !=   " 9 "  )  d.push_back( str );
        
        
while ( cin  >>  str   &&   str !=   " 9 "  )  d.push_back( str );
        
        sort( d.begin(), d.end() );
        
bool  isok =   false ;
        
for ( size_t i =   1 ; i <  d.size();  ++ i )
             
if ( d[i].find( d[i - 1 ] ) !=   string ::npos ) {
                    isok
=   true ;   break ; }

                    
        
if ! isok ) cout  <<   " Set  "   <<  num ++   <<   "  is immediately decodable "   <<  endl;
        
else         cout  <<   " Set  "   <<  num ++   <<   "  is not immediately decodable "   <<  endl;
    }

    
    
return   0 ;
}

你可能感兴趣的:(Pku 1056 IMMEDIATE DECODABILITY)