测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A22104. 下⾯程序使⽤动态规划求两个字符串的最长公共⼦序列(LCS)长度,横线处应填⼊的是( )。#include <algorithm> #include <string> #include <vector> usingnamespace std; int lcs_len(const string &a,const string &b){ int n =(int)a.size(), m =(int)b.…

单选题 困难

题目描述

下⾯程序使⽤动态规划求两个字符串的最长公共⼦序列(LCS)长度,横线处应填⼊的是(    )。

#include <algorithm>
#include <string>
#include <vector>
usingnamespace std;

int lcs_len(const string &a,const string &b){
    int n =(int)a.size(), m =(int)b.size();
    vector<vector<int>>dp(n +1,vector<int>(m +1,0));
    for(int i =1; i <= n;++i)
        for(int j =1; j <= m;++j)
            if(a[i -1]== b[j -1])
                dp[i][j]= dp[i -1][j -1]+1;
            else
                _____________;// 在此处填入选项
     return dp[n][m];
 }

选项(单选)

上一题 下一题