HDU 2594 Simpsons’ Hidden Talents(辛普森一家的潜在天赋) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) [Description] [题目描述] Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had. Marge:…
Simpsons’ Hidden Talents Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6888    Accepted Submission(s): 2461 Problem Description Homer: Marge, I just figured out a way to discover some of the…
Simpsons’ Hidden Talents Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4683    Accepted Submission(s): 1702 Problem Description Homer: Marge, I just figured out a way to discover some of the t…
Simpsons’ Hidden Talents Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4543    Accepted Submission(s): 1648 Problem Description Homer: Marge, I just figured out a way to discover some of the t…
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. Sample Input clinton homer riemann marjorie   Sample Output 0 rie 3   思路:要求的是s1的最长前缀是s2的后缀:那么kmp中的…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10513    Accepted Submission(s): 3671 Problem Description Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2594 思路:将两个串连起来求一遍Next数组就行长度为两者之和,遍历时注意长度应该小于两个串中的最小值 #include<cstdio> #include<iostream> #include<algorithm> #include<math.h> #include<string.h> #include<vector> #include&…
题意:两个字符串s.t,求s和t的最长的相同的前缀和后缀 思路:先求s的next数组,再求t的next数组(即代码中ex数组,此时不是自己与自己匹配,而是与s匹配),最后看ex[len2]即可(len2为串t的长度). #include<iostream> #include<stdio.h> #include<string.h> using namespace std; #define MaxSize 50005 int _next[MaxSize],ex[MaxSiz…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2594 题目大意:给两串字符串s1,s2,,找到最长子串满足既是s1的前缀又是s2的后缀,输出子串,及相应长度. 解题思路:这题是不是跟POJ 2752很像,没错,我们只要将s1.s2合并,不断递归直到找到长度小于等于s1.s2的公共前后缀即可. 代码 #include<iostream> #include<cstdio> #include<string> #include&…
题目链接:http://acm.acmcoder.com/showproblem.php?pid=2594 题意:求最长的串 同一时候是s1的前缀又是s2的后缀.输出子串和长度. 思路:kmp 代码: #include <vector> #include <string> #include <algorithm> #include <iostream> #include <stdio.h> #include <string.h> us…
Problem Description Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had.Marge: Yeah, what is it?Homer: Take me for example. I want to find out if I have a talent in politics, OK?Marge: OK.Homer: So I take so…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2594 这题直接用KMP算法就能够做出来,只是我还尝试了用扩展的kmp,这题用扩展的KMP效率没那么高. KMP算法: #include<stdio.h> #include<iostream> #include<string.h> using namespace std; int next[50001]; char p[50000],s[50000]; void getnex…
Simpsons' Hidden Talents Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4597    Accepted Submission(s): 1671 Problem Description Homer: Marge, I just figured out a way to discover some of the…
http://acm.hdu.edu.cn/showproblem.php?pid=2594 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9919    Accepted Submission(s): 3418 Problem Description Homer: Marge, I just figured out a way to…
http://acm.hdu.edu.cn/showproblem.php?pid=2594 Simpsons’ Hidden Talents Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4756    Accepted Submission(s): 1732 Problem Description Homer: Marge, I j…
Simpsons' Hidden Talents Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2798    Accepted Submission(s): 1055 Problem Description Homer: Marge, I just figured out a way to discover some of the…
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2594 题目: Simpsons’ Hidden Talents Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8709    Accepted Submission(s): 3051 Problem Description Homer: Mar…
题目链接:https://vjudge.net/problem/HDU-2594 Simpsons’ Hidden Talents Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10647    Accepted Submission(s): 3722 Problem Description Homer: Marge, I just f…
Simpsons’ Hidden Talents Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 259464-bit integer IO format: %I64d      Java class name: Main   Homer: Marge, I just figured out a way to discover some of the talents…
Simpsons’ Hidden Talents Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2875    Accepted Submission(s): 1095 Problem Description Homer: Marge, I just figured out a way to discover some of the t…
Simpsons’ Hidden Talents Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15015    Accepted Submission(s): 5151 Problem Description Homer: Marge, I just figured out a way to discover some of the…
Simpsons’ Hidden Talents Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1746 Accepted Submission(s): 637 Problem Description Homer: Marge, I just figured out a way to discover some of the talents…
Simpsons' Hidden Talents Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description Homer: Marge, I just figured out a way to discover some of the talents we weren't aware we had. Marge: Yeah, what is it? Hom…
题目大意:给你两个字符串,找出一个最大的子串,这个子串要是前面串的前缀并且是后面串的后缀...........   分析:next的简单运用吧,可以把两个串进行合并,中间加一个不能被匹配的字符,然后求出来next就行了.......确实很水 代码如下: ========================================================================================================= #include<stdio.h>…
Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had. Marge: Yeah, what is it? Homer: Take me for example. I want to find out if I have a talent in politics, OK? Marge: OK. Homer: So I take some politician’s…
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 8010 Accepted Submission(s): 2837 Problem Description Homer: Marge, I just figured out a way to discover some of the talents we weren't aware we had…
题意: 有两个字符串,找一个最长子串是的该串既是第一个字的前缀,又是第二个串的后缀. 分析: 把两个串并起来然后在中间加一个无关字符,求next数组即可. #include <cstdio> #include <cstring> + ; ], s2[maxn]; ], l; void get_next() { , j = ; next[] = -; while(j < l) { || s1[k] == s1[j]) { k++; j++; next[j] = k; } els…
Sample Input clinton homer riemann marjorie Sample Output 0 rie 3 看输出才题意...拓展kmp特征很明显嘛....注意开始就匹配到尾的情况 #include <iostream> #include <cstdio> #include <sstream> #include <cstring> #include <map> #include <set> #include &…
Problem Description Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had.Marge: Yeah, what is it?Homer: Take me for example. I want to find out if I have a talent in politics, OK?Marge: OK.Homer: So I take so…
求next数组,(一般有两种,求循环节用的见代码)求出循环节的长度. #include <cstdio> #define N 100005 int n,next[N]; char s[N]; int main(){ scanf("%d",&n); while(n--){ scanf("%s",s); int i=0,k=-1; next[0]=k; while(s[i]){ if(k==-1||s[i]==s[k]) { i++; k++; ne…