题意: 给定两个字符串 A 和 B,求最长公共子串. 分析: 字符串的任何一个子串都是这个字符串的某个后缀的前缀. 求 A 和 B 的最长公共子串等价于求 A 的后缀和 B 的后缀的最长公共前缀的最大值.如果枚举 A和 B 的所有的后缀,那么这样做显然效率低下. 由于要计算 A 的后缀和 B 的后缀的最长公共前缀,所以先将第二个字符串写在第一个字符串后面,中间用一个没有出现过的字符隔开,再求这个新的字符串的后缀数组. 观察一下,看看能不能从这个新的字符串的后缀数组中找到一些规律.以 A=“aaa…
题目链接:https://vjudge.net/problem/POJ-3294 Life Forms Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 16905 Accepted: 4970 Description You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial t…
题目:http://poj.org/problem?id=3294 Life Forms Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 18549 Accepted: 5454 Description You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial traits s…
题意:略 求最长公共子串 #include<iostream> #include<cstdio> #include<string> using namespace std; int dp[500][500]; int max(int a,int b) { return a>b?a:b; } int main() { int i,j,a,b; char s1[400],s2[400]; while(scanf("%s%s",s1,s2)!=EOF…
题目链接:https://vjudge.net/problem/POJ-3415 Common Substrings Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 12240 Accepted: 4144 Description A substring of a string T is defined as: T(i, k)=TiTi+1...Ti+k-1, 1≤i≤i+k-1≤|T|. Given two stri…
题目链接:https://vjudge.net/problem/POJ-3450 Corporate Identity Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 8046 Accepted: 2710 Description Beside other services, ACM helps companies to clearly state their “corporate identity”, which i…