| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:Why wa, not memory limit error?In Reply To:Why wa, not memory limit error? Posted by:anne2277 at 2005-06-30 10:32:41 A good method to solve this problem is to determine the length L of a longest common subsequence (maximal matching) for the input and its reverse. The answer then is N - L. An alternative approach is to match a prefix of the string with the reverse of a postfix. The length of a longest common subsequence can be determined by dynamic programming. A triangular table can be constructed, of which only two rows need to be stored. The complexity is then O(N) space and O(N^2) time. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator