Longest Common Substring Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5375    Accepted Submission(s): 1910 Problem Description Given two strings, you have to tell the length of the Longest Co…
\(\color{#0066ff}{ 题目描述 }\) 输入2 个长度不大于250000的字符串,输出这2 个字符串的最长公共子串.如果没有公共子串则输出0 . \(\color{#0066ff}{输入格式}\) 两个字符串 \(\color{#0066ff}{输出格式}\) 一个整数,为 所求答案 \(\color{#0066ff}{输入样例}\) alsdfkjfjkdsal fdjskalajfkdsla \(\color{#0066ff}{输出样例}\) 3 \(\color{#0066…
\(\color{purple}{Link}\) \(\text{Solution:}\) 题目要求找到两个串的最长公共子串.\(LCP\) 我们将两个串中间和末尾插入终止符,并弄到一棵后缀树上去. 然后我们发现,对于一个叶子节点,它属于哪个子串,我们只需要找到它的父边上第一个出现的终止符属于哪个边即可. 这里,我们可以用个奇技淫巧--前缀和实现. 介于\(\text{Suffix Tree}\)的边都是压缩的,所以维护信息变得不是很容易,所以可以采用一个在插入外面进行预处理前缀和的方式维护.…
知识点: SAM,SA,单调栈,Hash 原题面 Luogu 来自 poj 的双倍经验 简述 给定两字符串 \(S_1, S_2\),求它们的最长公共子串长度. \(|S_1|,|S_2|\le 2.5\times 10^5\). 294ms,1.46GB. 分析 以下将介绍四种效率不同的写法. 图片为按最优解排序后的结果,从上到下依次为 SAM.SA.自己 YY 的 SA 和 Hash. Hash 二分答案枚举最长公共子串长度 \(mid\). Check 时,将一个串所有长度为 \(mid\…
[SP1811]LCS - Longest Common Substring 题面 洛谷 题解 建好后缀自动机后从初始状态沿着现在的边匹配, 如果失配则跳它的后缀链接,因为你跳后缀链接到达的\(Endpos\)集合中的串肯定是当前\(Endpos\)中的后缀,所以这么做是对的. 你感性理解一下,这样显然是最大的是吧... 具体实现看代码: 代码 #include <iostream> #include <cstdio> #include <cstdlib> #inclu…
spoj 1811 LCS - Longest Common Substring 题意: 给出两个串S, T, 求最长公共子串. 限制: |S|, |T| <= 1e5 思路: dp O(n^2) 铁定超时 后缀数组 O(nlog(n)) 在spoj上没试过,感觉也会被卡掉 后缀自己主动机 O(n) 我们考虑用SAM读入字符串B; 令当前状态为s,同一时候最大匹配长度为len; 我们读入字符x.假设s有标号为x的边,那么s=trans(s,x),len = len+1; 否则我们找到s的第一个祖…
LCS - Longest Common Substring no tags  A string is finite sequence of characters over a non-empty finite set Σ. In this problem, Σ is the set of lowercase letters. Substring, also called factor, is a consecutive sequence of characters occurrences at…
地址:http://www.spoj.com/problems/LCS/ 题面: LCS - Longest Common Substring no tags  A string is finite sequence of characters over a non-empty finite set Σ. In this problem, Σ is the set of lowercase letters. Substring, also called factor, is a consecut…
A string is finite sequence of characters over a non-empty finite set Σ. In this problem, Σ is the set of lowercase letters. Substring, also called factor, is a consecutive sequence of characters occurrences at least once in a string. Now your task i…
A string is finite sequence of characters over a non-empty finite set \(\sum\). In this problem, \(\sum\) is the set of lowercase letters. Substring, also called factor, is a consecutive sequence of characters occurrences at least once in a string. N…