字符串
文章平均质量分 74
Interstellar_
这个作者很懒,什么都没留下…
展开
-
POJ 3461 Oulipo(KMP)
OulipoTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 35475 Accepted: 14348DescriptionThe French author Georges Perec (1936–1982) once wrote a book, La原创 2016-08-04 20:56:39 · 255 阅读 · 0 评论 -
UVALive 5913 Dictionary Size (Trie)
题目链接:https://vjudge.net/problem/UVALive-5913题目大意:给出n个旧单词,要从这n个旧单词中构造新单词。构造条件是 S = Sa + Sb,其中Sa为某个旧单词的非空前缀,Sb为某个单词的非空后缀。求所有的新单词和旧单词中有多少个不同的单词。思路:将所有单词建成一棵字典树,再将所有单词反转并建成一棵字典树。则第一棵树的结点个数即为不同原创 2017-08-24 10:29:19 · 382 阅读 · 0 评论 -
POJ 1743 Musical Theme (后缀树组)
DescriptionA musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the piano. It is unfortunate but true that this re原创 2017-08-27 19:32:31 · 253 阅读 · 0 评论 -
UVa 11148 Hyper Prefix Sets (Trie)
题目链接:https://vjudge.net/problem/UVA-11488题意:给定n个字符串,从n个字符串中选出若干个组成字符串集合S。定义P(S)为集合S中所有串的最长公共前缀长度与S中字符串个数的乘积。求一个集合S,使得P(S)最大。思路:首先将所有串建成一颗Trie树,然后遍历整个Trie树。当遍历到某个结点u时,从起始根节点往下到u构成了一个前缀,以这个为前缀的字符串个数原创 2017-08-23 17:01:10 · 307 阅读 · 0 评论 -
HDU 2243 考研路茫茫——单词情结(AC自动机+矩阵快速幂)
思路:本题和POJ2778几乎是一样的,所以可以借鉴那一道题的思路。首先求出长度不超过n的不包含任何词根的单词数,然后用总的单词数减去这种情况即可。#include#include#include#include#include#include#include#include#include#include#include#include#inc原创 2017-08-23 15:34:41 · 333 阅读 · 0 评论 -
UVALive 4126 Password Suspects (AC自动机+DP)
题目链接:https://vjudge.net/problem/UVALive-4126题目大意:有一个长度为n的未知小写字母串,你已经知道了它的一些连续子串(但不知道出现位置,这些字串可能相互重叠)。比如,若长度为10,有两个连续子串hello和world,则只有两种可能:helloworld和worldhello。求可能的串的个数,若个数不超过42,按字典序输出所有串。思路:将连续子串原创 2017-08-27 09:26:26 · 590 阅读 · 0 评论 -
UVALive 2755 Hidden Password (最小表示法)
题目链接:https://cn.vjudge.net/problem/UVALive-2755题目大意:求一个字符串的最小字典序表示思路:参考https://wenku.baidu.com/view/185b95d726fff705cc170a7a.html,复杂度为O(n)#include#include#include#include#include#includ原创 2017-08-25 09:43:11 · 285 阅读 · 0 评论 -
POJ 2778 DNA Sequence (AC自动机+矩阵快速幂)
题目链接:http://poj.org/problem?id=2778题目大意:给出m个病毒串。构造一个长度为n的串(由A、G、C、T组成),使其不包含任何一个病毒串,求方案数。思路:将病毒串构造AC自动机。接下来我们可以定义函数f(u, n)表示从自动机上的结点u出发,还需走n步的方案数,那么有f(u, n) = sigma( f(ch[u][v], m-1) ),其中u原创 2017-08-21 15:03:05 · 250 阅读 · 0 评论 -
HDU 6138 Fleet of the Eternal Throne (AC自动机)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6138题意:给出n个串以及m个询问,对于每个询问(x, y),回答串x和串y的最长公共连续子串,并且这个串还是n个串中任意一个串的前缀。思路:将这n个串建立AC自动机,每个节点保存其到根节点的距离(即前缀的长度)。首先将串x在自动机上跑一遍,将经过的节点做个标记(表示串x可以匹配到这些节点所代表原创 2017-08-20 11:27:55 · 339 阅读 · 0 评论 -
UVa 1401 Remember the Word (字典树, 动归)
题目链接:http://vjudge.net/problem/UV原创 2016-11-01 19:06:15 · 320 阅读 · 0 评论 -
HDU 1251 统计难题 (字典树)
统计难题Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others)Total Submission(s): 35573 Accepted Submission(s): 13301Problem DescriptionIgnatius最近遇到一个难题,老原创 2016-10-31 23:10:31 · 288 阅读 · 0 评论 -
POJ 3261 Milk Patterns (后缀树组)
DescriptionFarmer John has noticed that the quality of milk given by his cows varies from day to day. On further investigation, he discovered that although he can't predict the quality of milk fro原创 2017-08-27 19:41:55 · 326 阅读 · 0 评论