#CODEFORCESP7249. Autocomplete
Autocomplete
Autocomplete
题目描述
Autocomplete is a program function that enables inputting the text (in editors, command line shells, browsers etc.) completing the text by its inputted part. Vasya is busy working on a new browser called 'BERowser'. He happens to be working on the autocomplete function in the address line at this very moment. A list consisting of last visited by the user pages and the inputted part are known. Your task is to complete to make it an address of one of the pages from the list. You have to find the lexicographically smallest address having a prefix .
输入格式
The first line contains the line which is the inputted part. The second line contains an integer ( ) which is the number of visited pages. Then follow lines which are the visited pages, one on each line. All the lines have lengths of from to symbols inclusively and consist of lowercase Latin letters only.
输出格式
If is not the beginning of any of addresses of the visited pages, print . Otherwise, print the lexicographically minimal address of one of the visited pages starting from .
The lexicographical order is the order of words in a dictionary. The lexicographical comparison of lines is realized by the '<' operator in the modern programming languages.
题面翻译
题目描述
给定一个字符串 。此外还有 个字符串,你必须找到这 个字符串里,字典序最小的前缀为 的字符串。
如果没有符合条件的字符串(即这 个字符串均不以 作为前缀),那就输出 本身。
输入格式
第一行 ,第二行 ,之后 行为 个匹配字符串。
输出格式
一个字符串,如题面所求。
数据范围:
- 保证所有字符串都由小写字母组成
样例 #1
样例输入 #1
next
2
nextpermutation
nextelement
样例输出 #1
nextelement
样例 #2
样例输入 #2
find
4
find
findfirstof
findit
fand
样例输出 #2
find
样例 #3
样例输入 #3
find
4
fondfind
fondfirstof
fondit
fand
样例输出 #3
find
相关
在以下作业中: