对于一个给定长度为\(N\)的字符串,求它的第\(K\)小子串是什么. Input 第一行是一个仅由小写英文字母构成的字符串\(S\) 第二行为两个整数\(T\)和\(K\),\(T\)为0则表示不同位置的相同子串算作一个.\(T=1\)则表示不同位置的相同子串算作多个.\(K\)的意义如题所述. Output 输出仅一行,为一个数字串,为第\(K\)小的子串.如果子串数目不足\(K\)个,则输出\(-1\) Sample Input aabc 0 3 Sample Output aab Hin…
Given a string, we need to find the total number of its distinct substrings. Input \(T-\) number of test cases. \(T<=20\); Each test case consists of one string, whose length is \(<=1000\) Output For each test case output one number saying the numbe…
A string is finite sequence of characters over a non-empty finite set \(\sum\). In this problem, \(\sum\) is the set of lowercase letters. Substring, also called factor, is a consecutive sequence of characters occurrences at least once in a string. N…
A string is finite sequence of characters over a non-empty finite set \(\sum\). In this problem, \(\sum\) is the set of lowercase letters. Substring, also called factor, is a consecutive sequence of characters occurrences at least once in a string. N…
Little Daniel loves to play with strings! He always finds different ways to have fun with strings! Knowing that, his friend Kinan decided to test his skills so he gave him a string \(S\) and asked him \(Q\) questions of the form: If all distinct subs…
You are given a string \(S\) which consists of 250000 lowercase latin letters at most. We define \(F(x)\) as the maximal number of times that some string with length \(x\) appears in \(S\). For example for string 'ababa' \(F(3)\) will be 2 because th…
后缀自动机ins解释 void ins(int c){ int p=last;//将当前节点的parent节点变为last int np=++cnt;//建立新节点 last=np;//将last设为当前节点 l[np]=l[p]+1;//当前节点的长度为父节点+1 for(;p&&!ch[p][c];p=fa[p])//若当前点的parent没有c这个儿子,则往上跳 ch[p][c]=np;//跳的过程中把这些点的c这个儿子设为当前节点 if(!p)fa[np]=1;//若跳回到根,则p…
题目链接 \(Click\) \(Here\) 真的是好题啊-不过在说做法之前先强调几个自己总是掉的坑点. 更新节点永远记不住往上跳\(p = fa[p]\) 新建节点永远记不住\(len[y] = len[p] + 1\) 总之就是各种各样的智障错误啦! 来说这个题目.这个题目厉害就厉害在,你要想到怎么用只有\(20\)个叶子节点这个信息.对于任意一条树上的路径,它一定对应于以某个叶节点为根的树中,一条根节点发出的链上的后缀.既然叶节点只有\(20\)个,我们要做的就是换\(20\)次根就好了…
佳媛姐姐过生日的时候,她的小伙伴从某东上买了一个生日礼物.生日礼物放在一个神奇的箱子中.箱子外边写了 一个长为\(n\)的字符串\(s\),和\(m\)个问题.佳媛姐姐必须正确回答这\(m\)个问题,才能打开箱子拿到礼物,升职加薪,出任CE O,嫁给高富帅,走上人生巅峰.每个问题均有\(a,b,c,d\)四个参数,问你子串\(s[a..b]\)的所有子串和\(s[c..d]\)的最长公 共前缀的长度的最大值是多少?佳媛姐姐并不擅长做这样的问题,所以她向你求助,你该如何帮助她呢? Input 输入…
前言(2019.1.6) 已经是二周目了呢... 之前还是有一些东西没有理解到位 重新写一下吧 后缀自动机的一些基本概念 参考资料和例子 from hihocoder DZYO神仙翻译的神仙论文 简而言之,后缀自动机(SAM),是一个有限状态自动机(DFA) SAM分为两个部分,一部分是一个Dag,另一部分是Parent树.--laofu 搬一个图下来(这是字符串\(aabbabd\)的\(SAM\)) 后缀自动机的DAG部分 后缀的\(Dag\)(有向无环图)部分由状态和转移函数构成, 状态表…