/** *找str1中的一个子序列与str2相同 */ #include #include using namespace std; class Search { public: int s2_index_of_s1(const string &s1,const string &s2); priva... ...
分类:
其他好文 时间:
2019-03-16 23:41:58
阅读次数:
287
~~不想写题。不如写写算法总结?~~ KMP 介(che)绍(dan) 以前都不知道$KMP$为什么叫$KMP$,现在才明白:该算法是三位大牛: D.E.Knuth 、 J.H.Morris 和 V.R.Pratt 同时发现的,以其名字首字母命名。 $KMP$可以在$O(n+m)$的时间复杂度内解决 ...
分类:
其他好文 时间:
2019-03-15 19:23:03
阅读次数:
235
题意:给你T组数据,每组数据分别输入n,m和长度为n的数字数组,和长度为m的数字数组,问你长度为m的数组第一次出现在长度为n的数组的位置 解题思路:标准字符串匹配问题,一般用kmp解,拿来练hash ...
分类:
其他好文 时间:
2019-03-13 21:22:39
阅读次数:
209
#include<bits/stdc++.h>using namespace std;const int N=1000007;char s1[N],s2[N];int len1,len2;int nex[N];int cnt1[7],cnt2[7];int main(){ scanf("%s %s" ...
分类:
其他好文 时间:
2019-03-11 00:46:33
阅读次数:
203
题目传送门 题意:给出$s$和$t$两个串,让你构造出一个答案串,使得答案串中的01数量和s一样,并且使$t$在答案串中作为子串出现次数最多。 思路: 要想出现的次数尽可能多,那么就要重复的利用,哪一部分是可以重复利用的呢?就是前缀和后缀相同的部分,然后我们就想到了$kmp$算法中$fail$函数就 ...
分类:
其他好文 时间:
2019-03-10 22:18:37
阅读次数:
254
Problem Description Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also other ...
分类:
其他好文 时间:
2019-03-10 13:34:49
阅读次数:
126
$\DeclareMathOperator{\fail}{fail}$ KMP 算法堪称经典中的经典了,然而这么多年以来,我没能完全理解这个算法。我对 KMP 算法掌握的程度,就是知道其原理,但是写不出来。 今天打 CF,遇到一个 KMP 的题目,解法很好想,代码量也不大,我却未能在最后的 17 分 ...
分类:
编程语言 时间:
2019-03-09 12:52:22
阅读次数:
184
A:求出该行该列各有多少个比其小的取max,该行该列各有多少个比其大的取max,加起来即可。 B:kmp求出最长border,贪心的每次利用这个border制造新子串即可。 C:场上写了1h假题意。终于看懂题之后又被之前假题意的做法带偏了。考虑拆点,建出新图后缩点,跑最长链即为答案。因为由图的特殊性 ...
分类:
其他好文 时间:
2019-03-09 01:27:14
阅读次数:
244
Description Given 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 thin ...
分类:
其他好文 时间:
2019-03-08 17:14:02
阅读次数:
167
c语言自然是应用最最著名的kmp(看毛片)算法。 这个算法的理解可以参考: https://www.cnblogs.com/yjiyjige/p/3263858.html python: python是真的简单,运用切片就能达到想要的目的了。 ...
分类:
编程语言 时间:
2019-03-08 09:49:26
阅读次数:
185