上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 73 下一页
摘要: 题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2946 建出 n-1 个后缀自动机一起跑呗。 代码如下: 阅读全文
posted @ 2018-12-12 14:51 Zinn 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4032 序列自动机其实就是每个位置记录一下某字母后面第一个出现位置,为了子序列能尽量长。 对字符串B建一个后缀自动机,一个序列自动机,然后让A在上面找即可; 1.枚举A每个位置开始的子串,在SA 阅读全文
posted @ 2018-12-12 14:20 Zinn 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2555 建立后缀自动机,就可以直接加入新串了; 出现次数就是 Right 集合的大小,需要查询 Parent 树上的子树和; 所以可以用 LCT 维护 Parent 树,因为 Parent 树是 阅读全文
posted @ 2018-12-12 10:51 Zinn 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.luogu.org/problemnew/show/P3804 模仿了一篇题解,感觉很好写啊。 代码如下: 阅读全文
posted @ 2018-12-11 22:52 Zinn 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.luogu.org/problemnew/show/P4106 https://www.lydsy.com/JudgeOnline/problem.php?id=3614 从很小的情况考虑,看题面上的样例: x1=+1 x2=+1 0 x1=+1 x2=-1 1 x1= 阅读全文
posted @ 2018-12-11 13:10 Zinn 阅读(296) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=4609 算不合法的比较方便; 枚举最大的边,每种情况算了2次,而全排列算了6次,所以还要乘3; 注意枚举最大边的范围是 mx 而不是 lim !!否则会超过开的数组范围!!! 代码如下: 阅读全文
posted @ 2018-12-10 23:05 Zinn 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2865 唯一出现的子串就是每个后缀除去和别的后缀最长的 LCP 之外的前缀; 所以用这个更新一段区间的答案,可以用线段树维护; 在 sa[i] ~ sa[i]+LCP+1 位置的答案由 LCP+ 阅读全文
posted @ 2018-12-08 16:19 Zinn 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3796 先把三个串拼在一起,KMP 求 s1 , s2 中每个位置和 s3 的匹配情况; 注意拼三个串时加入的两个新字符不要一样,否则会影响; 然后预处理出每个位置后面的第一个 s3 的开头 — 阅读全文
posted @ 2018-12-08 00:06 Zinn 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4310 二分答案——在本质不同的子串中二分答案! 如果二分到的子串位置是 st,考虑何时必须分出一段; 如果一个位置 i 有 rk[i] < rk[st],那么显然不用管( i 后缀的开头); 阅读全文
posted @ 2018-12-07 20:15 Zinn 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3230 先算出每个后缀贡献子串的区间; 然后前缀LCP直接查询,后缀LCP二分长度,查询即可; 注意本质不同的子串的个数是 long long 级别!! 于是读入有 long long —— 快 阅读全文
posted @ 2018-12-07 17:17 Zinn 阅读(171) 评论(0) 推荐(0) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 73 下一页