博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
AtCoder - 4130 K-th Substring
阅读量:4680 次
发布时间:2019-06-09

本文共 1533 字,大约阅读时间需要 5 分钟。

Problem Statement

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=x1x2xn and Y=y1y2ym 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:

sK

Output

Print the K-th lexicographically smallest substring of K.

Sample Input 1

aba4

Sample Output 1

b

s has five substrings: ababba and aba. Among them, we should print the fourth smallest one, b. Note that we do not count a twice.

Sample Input 2

atcoderandatcodeer5

Sample Output 2

andat

Sample Input 3

z1

Sample Output 3

z     一看这种题第一反应:裸上SAM啊!     但是一看数据范围:艹这是连SAM都不用的傻逼题了。 因为字典序第K小肯定不会超过K位,所以直接暴力+去重就可以做了QWQ
#include
#define ll long longusing namespace std;const int maxn=5005;string ch[maxn*6];char s[maxn];int n,k,cnt;int main(){ scanf("%s%d",s,&k),n=strlen(s); for(int i=0,T;i
 

  

 

转载于:https://www.cnblogs.com/JYYHH/p/9037189.html

你可能感兴趣的文章
【JDK源码分析】 String.join()方法解析
查看>>
【SICP练习】112 练习3.28
查看>>
python--注释
查看>>
前端资源链接 ...
查看>>
yum install ntp 报错:Error: Package: ntp-4.2.6p5-25.el7.centos.2.x86_64 (base)
查看>>
leetcode-Single Number-136
查看>>
CF715C Digit Tree
查看>>
二分法练习1
查看>>
QT 制作串口调试小助手----(小白篇)
查看>>
前端MVC实践之hellorocket——by张舒彤
查看>>
OptimalSolution(2)--二叉树问题(3)Path路径问题
查看>>
IPC 之 Messenger 的使用
查看>>
爱情八十六课,等得不是爱情
查看>>
企业网站建设流程
查看>>
数据库的显示、创建、使用 、用户授权管理及忘记root用户后重置密码
查看>>
ES5和ES6中的继承 图解
查看>>
macos 下usb键盘问题.
查看>>
SQL函数学习(十六):STUFF()函数
查看>>
Apache Hadoop 和Hadoop生态圈
查看>>
Ctrl+Enter 选中文本提交
查看>>