| ||||||||||
| 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:如果MMEIn 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator