DescriptionGiven two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think...
分类:
其他好文 时间:
2015-07-18 12:30:39
阅读次数:
88
DescriptionFor each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whe...
分类:
其他好文 时间:
2015-07-18 12:23:05
阅读次数:
91
本文参考阮一峰老师的KMP算法,重点是“部分匹配表”的建立。算法可参考http://kb.cnblogs.com/page/176818/ 。/** kmp.cpp* Author: Qiang Xiao* Time: 2015-07-18*/#include#includeusing ...
分类:
编程语言 时间:
2015-07-18 07:02:23
阅读次数:
129
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2328题意:输入一个不为0的整数n,再输入n个字符串,求n个字符串的最长公共连续子序列,并保证字典序最小。题解:直接暴力枚举。Times:764msMemory:1892KB代码如下: 1 #inclu....
分类:
其他好文 时间:
2015-07-17 18:35:34
阅读次数:
105
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1238题意:给定n个字符串,求它们的最长连续子序列,值得注意的是,求的的子序列可以是反转的。题解:直接记录出最短的字符串作为匹配串,其实用第一个也应该是可以的,然后不断的缩小其长度,知道能够匹配成功,如果...
分类:
其他好文 时间:
2015-07-17 18:00:48
阅读次数:
164
扩展KMP,用于求s的后缀的最长前缀。用extand数组表示第i个后缀的最长前缀的字符个数。注意几点:1.next数组是对T的 2.extand数组是对S的 3.应用:回文,重复串等代码如下: 1 #include 2 #include 3 #include 4 using...
分类:
编程语言 时间:
2015-07-17 00:01:04
阅读次数:
386
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4300题意:说实话,看半天题目,愣是没看懂,百度题意才看懂,大概意思就是:第一个串串为匹配串,第i个代表字母顺序中的第i个,比如第一个是q,那么,q就代表a。第二个串是密文+明文,密文全部都有,但明文可能...
分类:
其他好文 时间:
2015-07-16 23:55:04
阅读次数:
140