The Little Elephant loves strings very much. He has an array a from n strings, consisting of lowercase English letters. Let's number the elements of the array from 1 to n, then let's denote the element number i as ai. For each string ai (1 ≤ i ≤ n) t
Longest Common Substring 给两个串A和B,求这两个串的最长公共子串. no more than 250000 分析 参照OI wiki. 给定两个字符串 S 和 T ,求出最长公共子串,公共子串定义为在 S 和 T 中 都作为子串出现过的字符串 X . 我们为字符串 S 构造后缀自动机. 我们现在处理字符串 T ,对于每一个前缀都在 S 中寻找这个前缀的最长后缀.换句话 说,对于每个字符串 T 中的位置,我们想要找到这个位置结束的 S 和 T 的最长公 共子串的长度. 为
后缀自动机(SAM) 为了方便,我们做出如下约定: "后缀自动机" (Suffix Automaton) 在后文中简称为 SAM . 记 \(|S|\) 为字符串 \(S\) 的长度. 记 \(\sum\) 为字符集,记 \(|\sum|\) 为字符集大小. 关于 SAM 的复杂度证明在 OI Wiki 上已经很全面了,这里只是希望可以帮助大家理解 SAM 是如何工作的以及一些应用,对这些不再多做证明. 在前几个部分中,你只需要跟着笔者给出的构建好的 SAM 图理解某些定义,不需要知道
C. Cyclical Quest time limit per test:3 seconds memory limit per test:512 megabytes input:standard input output: standard output Some days ago, WJMZBMR learned how to answer the query "how many times does a string x occur in a string s" quickly