码迷,mamicode.com
首页 > 其他好文 > 详细

ARC097C K-th Substring

时间:2018-05-21 19:49:35      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:arc   graphic   注意   div   input   The   and   letters   字符   

传送门

题目

You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one.

A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = ababcabab and ababc are substrings of s, while acz and an empty string are not. Also, we say that substrings are different when they are different as strings.

Let X=x1x2…xn and Y=y1y2…ym be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or xj>yj where j is the smallest integer such that xjyj.

Constraints

  • 1  |s|  5000
  • s consists of lowercase English letters.
  • 1  K  5
  • s has at least K different substrings.

Partial Score

  • 200 points will be awarded as a partial score for passing the test set satisfying |s|  50.

Input

Input is given from Standard Input in the following format:

s
K

Output

Print the K-th lexicographically smallest substring of K.

题目大意

给你一个字符串s,求它字典序第k大的字串

分析

因为k<=5,所以我们可以枚举字串的起始点和长度,以为长度小,我们把整个字串转化成数字然后排序即可,注意长度不满k的字串在末尾要补零

代码

ARC097C K-th Substring

标签:arc   graphic   注意   div   input   The   and   letters   字符   

原文地址:https://www.cnblogs.com/yzxverygood/p/9068423.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!