Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:如果MME

Posted by runformydream at 2009-08-20 10:24:11 on Problem 1159
In Reply To:接下面的算法,另一种解法。。(S与转置串的最长公共子序列) Posted by:ecjtuzxg at 2008-06-27 19:23:23
这种方法确实不错,但是写的时候如果按常规的话,会MME
所以可以用滚动数组来实现避免MME
if(p[i]==s[j]){
                     data[i%2][j]=data[(i-1)%2][j-1]+1;
                 }else{
                     data[i%2][j]=max(data[i%2][j-1],data[(i-1)%2][j]);
                 }
这样只要开到data[2][N]就可以了

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator