#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 阅读(403)
评论(0) 编辑 收藏 引用 所属分类:
动态规划