
manacher
tomjobs
别慌,慌也没用
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode 1745. 回文串分割 IV(分为三个回文串,manacher)
给你一个字符串 s ,如果可以将它分割成三个 非空 回文子字符串,那么返回 true ,否则返回 false 。 当一个字符串正着读和反着读是一模一样的,就称其为 回文字符串 。 示例 1: 输入:s = “abcbdd” 输出:true 解释:“abcbdd” = “a” + “bcb” + “dd”,三个子字符串都是回文的。 示例 2: 输入:s = “bcbddxy” 输出:false 解释:s 没办法被分割成 3 个回文子字符串。 提示: 3 <= s.length <= 2000 s原创 2021-09-15 21:37:47 · 486 阅读 · 0 评论 -
LeetCode 647. 回文子串(DP或马拉车)
给你一个字符串 s ,请你统计并返回这个字符串中 回文子串 的数目。 回文字符串 是正着读和倒过来读一样的字符串。 子字符串 是字符串中的由连续字符组成的一个序列。 具有不同开始位置或结束位置的子串,即使是由相同的字符组成,也会被视作不同的子串。 示例 1: 输入:s = “abc” 输出:3 解释:三个回文子串: “a”, “b”, “c” 示例 2: 输入:s = “aaa” 输出:6 解释:6个回文子串: “a”, “a”, “a”, “aa”, “aa”, “aaa” 提示: 1 <= s.l原创 2021-09-15 19:17:50 · 244 阅读 · 0 评论 -
2018ICPC南京 Problem M. Mediocre String Problem(回文串,马拉车,扩展KMP)
题意: 给你两个字符串s,ts,ts,t,要求从sss中找到一个子串和ttt的一个前缀拼起来,结果要是回文串。求多少种拼法。 思路: 借此题复习了一下字符串算法。 首先sss中找到的子串可以分为两部分:s1+s2s1+s2s1+s2,s1s1s1一定是ttt一个前缀的逆反串,s2s2s2一定是个回文串。 所以可以将一开始所给的sss串反一下,然后算出每个右端点iii对应回文串的个数,再找到[i+1,len][i+1,len][i+1,len]部分与ttt串的最长公共前缀,二者相乘就是答案。 算回文串的过程.原创 2021-01-17 22:39:48 · 284 阅读 · 0 评论 -
A - Accept or Reject Gym - 102448A(manacher)
This semester, various UFPE competitors had classes of a discipline called Theoretical Informatics. One of the major studied concepts was Turing Machines ™. A TM is basically a system that has a tape with infinite memory cells to the right and a head point原创 2020-06-29 14:06:32 · 507 阅读 · 0 评论 -
ICPC Central Europe Regional Contest 2019 A. ABB(马拉车,哈希)
Fernando was hired by the University of Waterloo to finish a development project the university started some time ago. Outside the campus, the university wanted to build its representative bungalow street for important foreign visitors and collaborators. C原创 2020-06-21 20:40:18 · 405 阅读 · 0 评论 -
Hotaru's problem HDU - 5371(manacher)
Hotaru Ichijou recently is addicated to math problems. Now she is playing with N-sequence. Let’s define N-sequence, which is composed with three parts and satisfied with the following condition: the ...原创 2020-01-26 20:51:55 · 352 阅读 · 0 评论 -
51nod1089 最长回文子串 V2(Manacher算法/哈希)
回文串是指aba、abba、cccbccc、aaaa这种左右对称的字符串。 输入一个字符串Str,输出Str里最长回文子串的长度。 输入 输入Str(Str的长度 <= 100000) 输出 输出最长回文子串的长度L。 输入样例 daabaac 输出样例 5 知乎上 https://www.zhihu.com/question/37289584 ”c加加编程思想“ 答主的回答很棒。 思路:...原创 2020-01-25 23:37:43 · 391 阅读 · 0 评论