CF128B.String
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
一天的信息技术课上,安娜和玛丽亚学习了字典序。
字符串 x 在字典序上小于字符串 y,当且仅当以下两个条件之一成立:
- x 是 y 的真前缀(即 x 是 y 的前缀且 x=y),或
- 存在某个下标 i(满足 1≤i≤min(∣x∣,∣y∣)),使得 xi<yi,且对任意 j(满足 1≤j<i)都有 xj=yj。
其中 ∣a∣ 表示字符串 a 的长度。现代编程语言中,字符串的字典序比较由运算符<实现。
老师给安娜和玛丽亚布置了作业:她给了她们一个长度为 n 的字符串。她们需要写出该字符串的所有子串(包括整个原始字符串),并且重复出现的子串也要分别列出(例如,对于字符串 "aab",应列出如下子串:"a"、"a"、"aa"、"ab"、"aab"、"b")。然后将这些子串按字典序升序排列。狡猾的老师并不想逐一检查所有这些子串,因此她只要求找出排序后列表中的第 k 个字符串。请帮助安娜和玛丽亚完成这项作业。
输入格式
The first line contains a non-empty string that only consists of small Latin letters ("a"-"z"), whose length does not exceed 105. The second line contains the only integer k (1 ≤ k ≤ 105).
第一行包含一个非空字符串,该字符串仅由小写拉丁字母(“a”–“z”)组成,其长度不超过 105。第二行包含唯一的一个整数 k(1 ≤ k ≤ 105)。
输出格式
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).
输出 Anna 和 Maria 所需的字符串——给定字符串的字典序第 k 个子串。如果子串总数少于 k,则输出字符串 "No such line."(不带引号)。
输入输出样例
输入#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".
在第二个样例中,字符串 “bc” 前面依次是字符串 “a”、“ab”、“abc”、“b”。
输入解题思路,AI测评打分。不知道怎么写?