hdu 1159 Common Subsequence

Posted zil17

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hdu 1159 Common Subsequence相关的知识,希望对你有一定的参考价值。

hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    while(cin>>s1>>s2){
        int l1=s1.size(),l2=s2.size();
        vector<vector<int>> dp(l1+1,vector<int>(l2+1,0));
        for(int i=1;i<=l1;++i){
            for(int j=1;j<=l2;++j){
                if(s1[i-1]==s2[j-1])
                    dp[i][j]=dp[i-1][j-1]+1;
                else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
        printf("%d\n",dp[l1][l2]);
    }
    return 0;
}

 

以上是关于hdu 1159 Common Subsequence的主要内容,如果未能解决你的问题,请参考以下文章

HDU 1159 Common Subsequence

HDU 1159 Common Subsequence(裸LCS)

hdu 1159 Common Subsequence(最长公共子序列)

hdu-1159 Common Subsequence

题解报告:hdu 1159 Common Subsequence

hdu 1159 Common Subsequence(lcs)