BestCoder Round #49 HDU5340 Three Palindromes Manacher算法
来源:互联网 发布:f450破解用户数软件 编辑:程序博客网 时间:2024/06/05 10:44
Three Palindromes
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1402 Accepted Submission(s): 474
Problem Description
Can we divided a given string S into three nonempty palindromes?
Input
First line contains a single integer T≤20 which denotes the number of test cases.
For each test case , there is an single line contains a string S which only consist of lowercase English letters.1≤|s|≤20000
For each test case , there is an single line contains a string S which only consist of lowercase English letters.
Output
For each case, output the "Yes" or "No" in a single line.
Sample Input
2abcabaadada
Sample Output
YesNo
Source
BestCoder Round #49 ($)
出题人:
对原串前缀和后缀作一个01标记pre[i],suf[i]表示1-i和i-n能否能形成回文。
记以i为中心的回文半径为r(i)。这些都可以在O(N)时间内求出。
也可以使用Hash+二分等方法O(NlogN)内求出。
我们考虑中间一个回文串的位置,不妨设它是奇数长度(偶数类似)。
那么问题变成了求一个i和d使得1<=d<=r(i)且pre[i-d]和suf[i+d]为真。
枚举i,实际上就是问pre[i-r(i)..i-1]和suf[i+1..i+r(i)]取反后
这两段有没有一个位置两者均为1,也就是and后不为0,
暴力压位即可。总时间复杂度为O(N2/32)。
我用的Manacher算法:
0 0
- BestCoder Round #49 Three Palindromes 即 hdu5340 (manacher算法)
- BestCoder Round #49 HDU5340 Three Palindromes Manacher算法
- HDU5340 Three Palindromes <Manacher>
- hdu5340 Three Palindromes(manacher算法)
- hdu5340--Three Palindromes(Mannacer算法)
- BestCoder Round #49 ($) HDOJ5340 Three Palindromes(暴力)
- HDU5340.Three Palindromes
- HDU5340 Three Palindromes
- HDU5340-Three Palindromes
- HDU 5340 Three Palindromes ——BestCoder Round #49
- BestCoder Round #49 ($) HDU 5340 Three Palindromes(1002)
- HDU 5340-Three Palindromes(Manacher算法)
- hdu-5340 Three Palindromes(Manacher 算法)
- HDU 5340 Three Palindromes (manacher算法)
- hdu 5340 Three Palindromes 【Manacher】
- hdu5340&Bestcoder(#49)b题
- hdu 5340 Three Palindromes(manacher)
- HDU 5340 Three Palindromes(Manacher乱搞)
- bzoj3209
- SVN使用教程之-分支/标记 合并 subeclipse
- 转到印象笔记
- POJ 2184 Cow Exhibition(01背包问题)
- 【转】EL表达式 (详解)
- BestCoder Round #49 HDU5340 Three Palindromes Manacher算法
- 数论+dp状压 Codeforces510D Fox And Jumping
- WINCE+6410 拨号上网
- strlen和sizeof的区别
- Maven3 安装 和 Myeclipse 配置
- UVALive 7004(计算几何 判断点与多边形的关系)
- 【Java Web 学习笔记】JSP开发环境搭建
- 解决mac OSX下安装git出现的"git命令需要使用开发者工具。您要现在安装该工具吗"
- BZOJ 1510 [POI2006]Kra-The Disks 二分