4493: DNA 题目连接: http://acm.scu.edu.cn/soj/problem.action?id=4493 Description Deoxyribonucleic acid (DNA) is a molecule that carries most of the genetic instructions used in the development, functioning and reproduction of all known living organisms a…
http://codevs.cn/problem/3160/ 后缀自动机板子题,匹配的时候要注意如果到一个点失配向前匹配到一个点时,此时的tmp(当前匹配值)为t[j].len+1而不是t[t[j].sig[z]].len,想一下自动机的特质就可以明白了. #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #inclu…
Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 25752   Accepted: 10483 Case Time Limit: 1000MS Description The little cat is majoring in physics in the capital of Byterland. A piece of sad news comes to him these days…
bzoj4032/luoguP4112 [HEOI2015]最短不公共子串(后缀自动机+序列自动机上dp) bzoj Luogu 题解时间 给两个小写字母串 $ A $ , $ B $ ,请你计算: (1) $ A $ 的一个最短的子串,它不是 $ B $ 的子串 (2) $ A $ 的一个最短的子串,它不是 $ B $ 的子序列 (3) $ A $ 的一个最短的子序列,它不是 $ B $ 的子串 (4) $ A $ 的一个最短的子序列,它不是 $ B $ 的子序列 水题四合一,一题更比四题sa…
3160 最长公共子串 题目描述 Description 给出两个由小写字母组成的字符串,求它们的最长公共子串的长度. 输入描述 Input Description 读入两个字符串 输出描述 Output Description 输出最长公共子串的长度 样例输入(Sample Input) yeshowmuchiloveyoumydearmotherreallyicannotbelieveit yeaphowmuchiloveyoumydearmother 样例输出(Sample Output)…
3160 最长公共子串 时间限制: 2 s 空间限制: 128000 KB 题目等级 : 大师 Master 题目描述 Description 给出两个由小写字母组成的字符串,求它们的最长公共子串的长度. 输入描述 Input Description 读入两个字符串 输出描述 Output Description 输出最长公共子串的长度 样例输入 Sample Input yeshowmuchiloveyoumydearmotherreallyicannotbelieveit yeaphowmu…
题目:http://poj.org/problem?id=2774 Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 36438   Accepted: 14614 Case Time Limit: 1000MS Description The little cat is majoring in physics in the capital of Byterland. A piece o…
题目描述 给出两个由小写字母组成的字符串,求它们的最长公共子串的长度. 输入 读入两个字符串 输出 输出最长公共子串的长度 样例输入 yeshowmuchiloveyoumydearmotherreallyicannotbelieveit yeaphowmuchiloveyoumydearmother 样例输出 27 题解 很直白的一道题. 将两个字符串串接起来,中间用未出现过的字符隔开 然后求height. 二分答案并判断即可. 模板题一道. #include <cstdio> #inclu…
4032: [HEOI2015]最短不公共子串 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4032 Description 在虐各种最长公共子串.子序列的题虐的不耐烦了之后,你决定反其道而行之. 一个串的"子串"指的是它的连续的一段,例如bcd是abcdef的子串,但bde不是. 一个串的"子序列"指的是它的可以不连续的一段,例如bde是abcdef的子串,但bdd不是. 下面,给两个小写字母串A,B…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4032 序列自动机其实就是每个位置记录一下某字母后面第一个出现位置,为了子序列能尽量长. 对字符串B建一个后缀自动机,一个序列自动机,然后让A在上面找即可: 1.枚举A每个位置开始的子串,在SAM上走,失配就找到了: 2.枚举A子串,用B的序列自动机找失配处: 3.设 f[i][j] 表示A串前 i 个字符形成的子序列对应SAM上节点 j 时的最短子序列长度,可以转移: 4.f[i][j]…