/ OPS / 题库 /

Travel Games

Travel Games

#描述#
Some are playing a travel game while they are taking a travel.
<BR>
In this game, the first one thinks of a three letter word from the Sacred Travel Game Dictionary (STGD). The next one in line must add a letter to the word (at the beginning, between two letters, or at the end) to make another word in the STGD. They are curious as to just how big the final word can be.

<BR>
<BR>
Given a dictionary of D (1 <= D <= 1000) words and a starting word, find any of the longest possible words that can be formed playing this travel game.

#格式#
##输入格式##
Many cases. In each case,first line is a integer D followed by a space followed by a legal three letter word.
And then D lines Each line contains a legal word no longer than 80 characters, consisting only of lowercase letters, from the STGD.

##输出格式##

A single line with the longest word that can be formed by extending the input seed for each case.
The input ensure the correct result will be unique.

#样例1#
##样例输入1##

9 cal
cal
calf
calfs
call
calls
choral
chorale
coal
coral

##样例输出1##

chorale

#限制#
1000ms
32768KB

#提示#
[From the sequence: cal, coal, coral, choral, chorale]

#来源#
daimin

信息

ID
1670
难度
5
分类
category1 点击显示
标签
递交数
0
已通过
0
通过率
?
上传者