ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1297. Palindrome

My idea for O(n) but wrong for test #5
Posted by AnhDQ 30 Apr 2008 17:57
F[i]: the longest Palindrom ended at St[i]
Cont[i]: the number of continue same characters with St[i], ended at St[i]

if St[i] = St[i - F[i - 1] - 1] then
  F[i] = F[i - 1] + 2
else
  if St[i] = St[i - 1] then
    F[i] = Cont[i];

The result is Max(F)

What's wrong with it ???
Re: My idea for O(n) but wrong for test #5
Posted by Alias aka Alexander Prudaev 30 Apr 2008 19:47
aabbbaabbb
it is wrong algorithm
Re: My idea for O(n) but wrong for test #5
Posted by wwwaaannngggrs 15 Jul 2010 15:22
The only O(n) Algotithm is suffix tree+LCA
or Suffix array + +-1RMQ+LCA+Catersian Tree
AnhDQ wrote 30 April 2008 17:57
F[i]: the longest Palindrom ended at St[i]
Cont[i]: the number of continue same characters with St[i], ended at St[i]

if St[i] = St[i - F[i - 1] - 1] then
  F[i] = F[i - 1] + 2
else
  if St[i] = St[i - 1] then
    F[i] = Cont[i];

The result is Max(F)

What's wrong with it ???
Re: My idea for O(n) but wrong for test #5
Posted by Hristian Hristov 8 Oct 2011 19:28
That's wrong! There's another O(n) algorithm. It's called Manacher's algorithm.
Re: My idea for O(n) but wrong for test #5
Posted by Hristian Hristov 9 Oct 2011 02:10


Edited by author 09.10.2011 02:10