A8319 | String
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
One day in the IT lesson Anna and Maria learned about the lexicographic order.
String $x$ is lexicographically less than string $y$ , if either $x$ is a prefix of $y$ (and $x≠y$ ), or there exists such $i$ ( $1<=i<=min(|x|,|y|)$ ), that $x_{i}<y_{i}$ , and for any $j$ ( $1<=j<i$ ) $x_{j}=y_{j}$ . Here $|a|$ denotes the length of the string $a$ . The lexicographic comparison of strings is implemented by operator < in modern programming languages.
The teacher gave Anna and Maria homework. She gave them a string of length $n$ . They should write out all substrings of the given string, including the whole initial string, and the equal substrings (for example, one should write out the following substrings from the string "aab": "a", "a", "aa", "ab", "aab", "b"). The resulting strings should be sorted in the lexicographical order. The cunning teacher doesn't want to check all these strings. That's why she said to find only the $k$ -th string from the list. Help Anna and Maria do the homework.
String $x$ is lexicographically less than string $y$ , if either $x$ is a prefix of $y$ (and $x≠y$ ), or there exists such $i$ ( $1<=i<=min(|x|,|y|)$ ), that $x_{i}<y_{i}$ , and for any $j$ ( $1<=j<i$ ) $x_{j}=y_{j}$ . Here $|a|$ denotes the length of the string $a$ . The lexicographic comparison of strings is implemented by operator < in modern programming languages.
The teacher gave Anna and Maria homework. She gave them a string of length $n$ . They should write out all substrings of the given string, including the whole initial string, and the equal substrings (for example, one should write out the following substrings from the string "aab": "a", "a", "aa", "ab", "aab", "b"). The resulting strings should be sorted in the lexicographical order. The cunning teacher doesn't want to check all these strings. That's why she said to find only the $k$ -th string from the list. Help Anna and Maria do the homework.
输入格式
The first line contains a non-empty string that only consists of small Latin letters ("a"-"z"), whose length does not exceed $10^{5}$ . The second line contains the only integer $k$ ( $1<=k<=10^{5}$ ).
输出格式
Print the string Anna and Maria need — the $k$ -th (in the lexicographical order) substring of the given string. If the total number of substrings is less than $k$ , print a string saying "No such line." (without the quotes).
输入输出样例
输入 #1
aa 2
输出 #1
a
输入 #2
abc 5
输出 #2
bc
输入 #3
abab 7
输出 #3
b
In the second sample before string "bc" follow strings "a", "ab", "abc", "b".
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted