HDOJ(1238) KMP】的更多相关文章

Substrings http://acm.hdu.edu.cn/showproblem.php?pid=1238 先找到长度最短的字符串,把它的子串和该子串的逆序(按长度从大到小)依次与其他字符串匹配. 如果某个子串或它的逆序(如:“ro” ,”or“)和其他字符串都匹配,就返回此时的长度. #include<iostream> #include<cstdio> #include<string> #include<vector> #include<a…
HDOJ 1238 Substrings [最长公共子串] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11430 Accepted Submission(s): 5490 Problem Description You are given a number of case-sensitive strings of alphabetic…
题目:   Sample Input 3 BAPC BAPC AZA AZAZAZA VERDI AVERDXIVYERDIAN   Sample Output 1 3 0     代码:   #include<iostream>#include<cstdio>#include<cstring>using namespace std;const int maxn1=1000010;const int maxn2=10010;int n,m;char a[maxn1];c…
http://acm.hdu.edu.cn/showproblem.php?pid=1238 Substrings Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1238 Description You are given a number of case-sensitive strings of alphabetic characte…
HDOJ 2203 亲和串 [KMP] Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 16573 Accepted Submission(s): 7273 Problem Description 人随着岁数的增长是越大越聪明还是越大越笨,这是一个值得全世界科学家思考的问题,同样的问题Eddy也一直在思考,因为他在很小的时候就知道亲和串如何判…
Cyclic Nacklace Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4212    Accepted Submission(s): 1913 Problem Description CC always becomes very depressed at the end of this month, he has checked…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5311 思路分析:该问题要求在字符串中是否存在三个不相交的子串s[l1..r1], s[l2..r2], s[l3..r3]能够拼接成模式串,而且满足要求1≤l1≤r1<l2≤r2<l3≤r3≤n: 由于数据较小,可见将模式串拆分为所有的三个不想交的子串的所有可能,再使用KMP算法求在字符串中是否存在这三个子串且满足顺序要求即可: 代码如下: #include <cstdio> #inc…
Problem Description You are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found as a substring of any of the given strings.   Input The first line of the input…
Oulipo Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7200    Accepted Submission(s): 2867 Problem Description The French author Georges Perec (1936–1982) once wrote a book, La disparition, wi…
题目传送门 题意:完全不懂,最后还是看题解才理解了.第一行字符串是密文变成明文的规则,比如第二个样例:“qwertyuiopasdfghjklzxcvbnm”,‘q'对应的明文为’a','w'对应'b'....... 第二行是密文+明文的形式,明文有密文转换来,但不完整,求原来最小的可能文本. 分析:将密文+明文都当做密文转成明文,那么转换后的字符串前缀密文的部分解密,和原来的字符串的后缀明文匹配,从原来字符串的后半部分和转换之后的字符串的开头开始匹配,得到的是明文(密文)的长度.详细解释 收获…