#include  < map >
#include 
< cstdio >

using   namespace  std;

struct  Node
{
    
char   a, b;
    Node()
{}
    Node( 
char  x, char  y):a(x),b(y) {}
}
;

bool   operator <  ( Node x, Node y )
{
    
if ( x.a ==  y.a )
    
return  x.b <  y.b;
    
return  x.a <  y.a;
}


int  main()
{
    
char  str[ 80 ];
    
    
while ( gets(str), str[ 0 ] !=   ' * '  )
    
{
        
bool  b =   true ;
        
        
for int  t =   1 ; t <  strlen(str);  ++ t )
        
{    
            map
< Node, int >  d;
            
bool  isok =   true ;
            
            
for int  i =   0 ; i <  strlen(str);  ++ i )
            
{
                
if ( (i + t) <  strlen(str)  &&  d[ Node( str[i], str[t +  i] ) ] ==   0  )
                     d[ Node( str[i], str[t
+  i] ) ] =   1 ;
                
else   if ( (i + t) <  strlen(str)  &&  d[ Node( str[i],str[t +  i]) ] ==   1  )
                
{
                     isok
=   false ;
                     
break ;
                }

            }

            
            
if ! isok )
            
{
                b
=   false ;
                
break ;
            }
    
        }

        
        
if ( b )   printf( " %s is surprising.\n " ,str); 
        
else       printf( " %s is NOT surprising.\n " ,str); 
    }

    
    
return   0 ;
}

posted on 2008-10-10 12:18 Darren 阅读(381) 评论(0)  编辑 收藏 引用 所属分类: 动态规划

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理