hdoj 5311 Hidden String(KMP)】的更多相关文章

题目链接: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…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5311 Hidden String Description Today is the 1st anniversary of BestCoder. Soda, the contest manager, gets a string s of length n. He wants to find three nonoverlapping substrings $s[l_1..r_1], s[l_2..r_2…
http://acm.hdu.edu.cn/showproblem.php?pid=5311 Hidden String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1499    Accepted Submission(s): 534 Problem Description Today is the 1st anniversar…
Hidden String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 52    Accepted Submission(s): 25 Problem Description Today is the 1st anniversary of BestCoder. Soda, the contest manager, gets a…
题意:今天是BestCoder一周年纪念日. 比赛管理员Soda有一个长度为n的字符串s. 他想要知道能否找到s的三个互不相交的子串s[l1..r1], s[l2..r2], s[l3..r3]满足下列条件: 1. 1≤l1≤r1<l2≤r2<l3≤r3≤n 2. s[l1..r1], s[l2..r2], s[l3..r3]依次连接之后得到字符串"anniversary". 特别注意:式子中红色符号!!! 思路:其实就是要在一个串中找可能存在的3个连续子串来构成这个&qu…
Problem Description Today is the 1st anniversary of BestCoder. Soda, the contest manager, gets a string s of length n. He wants to find three nonoverlapping substrings s[l1..r1], s[l2..r2], s[l3..r3] that: . ≤l1≤r1<l2≤r2<l3≤r3≤n . The concatenation…
BC一周年的题.这道题做比赛的时候A了小数据,终于评判的时候还是挂了,看来还是不认真思考的问题啊.交的时候 都没有信心过肯定是不行的.认真思考.敲一发,有信心过才是真正的acmer.赛后认真想了想,发现了好多bug,我 用的3层循环暴力做的.认真思考后敲的,认真思考后敲的.认真思考后敲的(重要的事说三遍) 贴代码: #include<stdio.h> #include<stdlib.h> #include<string.h> char a[105]; char b[20…
Hidden String  Accepts: 437  Submissions: 2174  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 262144/262144 K (Java/Others) 问题描述 今天是BestCoder一周年纪念日. 比赛管理员Soda有一个长度为n的字符串s. 他想要知道能否找到s的三个互不相交的子串s[l1..r1], s[l2..r2], s[l3..r3]满足下列条件: 1. 1≤l1≤r1<…
B. Hidden String Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=610&pid=1002 Description 今天是BestCoder一周年纪念日. 比赛管理员Soda有一个长度为n的字符串s. 他想要知道能否找到s的三个互不相交的子串s[l1..r1], s[l2..r2], s[l3..r3]满足…
Hidden String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 1679    Accepted Submission(s): 591 Problem Description Today is the 1st anniversary of BestCoder. Soda, the contest manager, get…
Hidden String Accepts: 437 Submissions: 2174 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) 问题描写叙述 今天是BestCoder一周年纪念日. 比赛管理员Soda有一个长度为n的字符串s. 他想要知道是否能找到s的三个互不相交的子串s[l1..r1], s[l2..r2], s[l3..r3]满足下列条件: 1. 1≤l1≤r1<l…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=5311 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1462    Accepted Submission(s): 521 Problem Description Today is the 1st anniversary of BestC…
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): 1746 Accepted Submission(s): 637 Problem Description Homer: Marge, I just figured out a way to discover some of the talents…
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…
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中的…
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 s, we can write down all the non-empty prefixes of this string. For example:s: "abab"The prefi…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3336 很容易想到用kmp 这里是next数组的应用 定义dp[i]表示以s[i]结尾的前缀的总数 那么dp[i]=dp[next[i]]+1; 代码: #include<stdio.h> #include<string.h> ; ; int dp[MAXN]; char str[MAXN]; int next[MAXN]; void getNext(char *p) { int j,k…
问题描述众所周知,aekdycoin擅长字符串问题和数论问题.当给定一个字符串s时,我们可以写下该字符串的所有非空前缀.例如:S:“ABAB”前缀是:“A”.“AB”.“ABA”.“ABAB”对于每个前缀,我们可以计算它在s中匹配的次数,因此我们可以看到前缀“a”匹配两次,“ab”也匹配两次,“ab a”匹配一次,“ab ab”匹配一次.现在,您需要计算所有前缀的匹配时间之和.对于“abab”,它是2+2+1+1=6.答案可能非常大,因此输出答案mod 10007. 输入第一行是一个整数t,表示…
It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can write down all the non-empty prefixes of this string. For example:  s: "abab"  The prefixes are: "a", "ab&…
翻转子串 參与人数:1197时间限制:3秒空间限制:32768K 通过比例:35.03% 最佳记录:0 ms|8552K(来自 ) 题目描写叙述 假定我们都知道很高效的算法来检查一个单词是否为其它字符串的子串.请将这个算法编写成一个函数.给定两个字符串s1和s2.请编写代码检查s2是否为s1旋转而成.要求仅仅能调用一次检查子串的函数. 给定两个字符串s1,s2,请返回bool值代表s2是否由s1旋转而成.字符串中字符为英文字母和空格,区分大写和小写,字符串长度小于等于1000. 測试例子: "H…
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…
题目链接:https://vjudge.net/problem/HDU-3336 Count the string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11760    Accepted Submission(s): 5479 Problem Description It is well known that AekdyCoi…
题目链接: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…
B. Obsessive String   Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started thinking about the following proble…
链接: https://vjudge.net/problem/HDU-2594#author=0 题意: 求S1的前缀和S2的后缀的<最大>匹配 思路: kmp方法: 将s1, s2首尾连接, 根据Next数组求, 注意长度要比s1, 和s2的长度小. ExtenKmp: 考虑以s1为模板串, 匹配s2, 对于第一个满足exten[i]+i == len的点, 就为最长的长度. 代码: #include <iostream> #include <cstdio> #inc…
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…
String painter Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2520    Accepted Submission(s): 1134 Problem Description There are two strings A and B with equal length. Both strings are made up…
D - Count the string Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can wr…
这道题本来想对了,可是因为hdu对pascal语言的限制是我认为自己想错了,结果一看题解发现自己对了…… 题意:给以字符串 计算出以前i个字符为前缀的字符中 在主串中出现的次数和 如: num(abab)=num(a)+num(ab)+num(aba)+num(abab)=2+2+1+1=6; 题解:next[i]记录的是 长度为i 不为自身的最大首尾重复子串长度  num[i]记录长度为next[i]的前缀所重复出现的次数 推介一篇博文,非常不错,和本代码解法不一样,但实质上是一样的. 附上代…