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

WA #17
Posted by Butusov Eugene 27 Sep 2010 19:04
My program read string S from the input and create reverse string R from the source string. Then I search in cycle with prefix function maximum suffix which may be prefix on string S.substr(i, S.length()-i)+R   i - the number of the iteration.
Then I check if the getting string the palindrome, I remember then offset and length of the string. In the end print maximum substring. Got WA on 17 test.

Thanks on the future...:)
Re: WA #17
Posted by Baurzhan 27 Sep 2010 23:31
1) First of all, you should compute prefix function on string
S.substr(i, S.length()-i)+R.substr(0,S.lenght()-i);
2) add '#' between original string and reverse string:
because on test "aaa" correct answer is "aaa" while your programm seems to output "aaaaa".
P.S I'm not sure my advices wiil help you,so just write here your mail and i'll send you AC code - my idea is the same with yours but i don't check palindroms - prefix fuction makes by itself!
Re: WA #17
Posted by Butusov Eugene 28 Sep 2010 00:54
Oh, I insert on concatenating between strings (original and reverse) '#' symbol and got AC!
Re: WA #17
Posted by Didi (OSU11) 8 Aug 2015 04:36
This test 'abcdesdfssaaaassss' show my Error with Manaker algorithm.