随笔分类 -  数据结构-KMP

摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5769 题意:在S串中找出X串出现的不同子串的数目? 其中1 <= |S| < $10^5$ 官方题解: 处理出后缀数组中的sa[]数组和height[]数组。在不考虑包含字符X的情况下,不同子串的个数为 如果要求 阅读全文
posted @ 2016-07-31 23:37 hxer 阅读(224) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5510 题意:至多50组数据,每组数据至多500个字符串,每个字符串的长度最长为2000.问最大的下标(从1开始)j,使得存在i < j使得s[i]不是s[j]的子串; 思路:KMP很容易想到,因为Tri 阅读全文
posted @ 2016-04-01 16:37 hxer 阅读(154) 评论(0) 推荐(0)
摘要:Clairewd’s message 题意:先一个转换表S,表示第i个拉丁字母转换为s[i],即a -> s[1];(a为明文,s[i]为密文)。之后给你一串长度为n<= 100000的前面为密文后面为明文的串;让你通过密码转换表S在这个串的后面添加字符,使得前面的密文翻译成明文之后与后面相对应,最 阅读全文
posted @ 2016-03-12 19:31 hxer 阅读(194) 评论(0) 推荐(0)
摘要:Simpsons’ Hidden Talents Problem Description Write a program that, when given strings s1 and s2, finds the longest prefix of s1 that is a suffix of s2 阅读全文
posted @ 2016-03-12 15:46 hxer 阅读(201) 评论(0) 推荐(0)
摘要:剪花布条 Problem Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input 输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见 阅读全文
posted @ 2016-03-12 14:08 hxer 阅读(193) 评论(0) 推荐(0)
摘要:Cyclic Nacklace 题意:给一个长度为Len( 3 <= Len <= 100000 )的英文串,问你在字符串后面最少添加几个字符可以使得添加后的串为周期串? Sample Input 3 aaa abca abcde Sample Output 0 2 5 思路:要是写过period再 阅读全文
posted @ 2016-03-12 13:53 hxer 阅读(205) 评论(0) 推荐(0)
摘要:Period 题意:一个长为N (2 <= N <= 1 000 000) 的字符串,问前缀串长度为k(k > 1)是否是一个周期串,即k = A...A;若是则按k从小到大的顺序输出k即周期数; Sample Input 3 aaa 12 aabaabaabaab 0 Sample Output 阅读全文
posted @ 2016-03-12 11:20 hxer 阅读(585) 评论(0) 推荐(0)
摘要:Count the string Problem Description It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string 阅读全文
posted @ 2016-03-12 10:59 hxer 阅读(210) 评论(0) 推荐(0)