Comments
On runtime_error → palindromes, 13 years ago
0

I don't know the manacher's algorithm but i can presume that the reason of TLE is the using string objects. They aren't efficient enough for such manipulation. Try to replace strings with char arrays.

http://acm.timus.ru/problem.aspx?space=1&num=1562 But this problem is quite simpler than the ones you've shown and won't require Simpson's formula. ;)

Seems like you are iterating the whole grid... of course it'll get TLE.
Try to iterate only cells of the frame of the rectangle.