A8031 | Autocomplete
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $n$ last visited by the user pages and the inputted part $s$ are known. Your task is to complete $s$ to make it an address of one of the pages from the list. You have to find the lexicographically smallest address having a prefix $s$ .
输入格式
The first line contains the $s$ line which is the inputted part. The second line contains an integer $n$ ( $1<=n<=100$ ) which is the number of visited pages. Then follow $n$ lines which are the visited pages, one on each line. All the lines have lengths of from $1$ to $100$ symbols inclusively and consist of lowercase Latin letters only.
输出格式
If $s$ is not the beginning of any of $n$ addresses of the visited pages, print $s$ . Otherwise, print the lexicographically minimal address of one of the visited pages starting from $s$ .
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.
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
next 2 nextpermutation nextelement
输出 #1
nextelement
输入 #2
find 4 find findfirstof findit fand
输出 #2
find
输入 #3
find 4 fondfind fondfirstof fondit fand
输出 #3
find
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted