KY114 Coincidence

2024-02-06 19:44
文章标签 coincidence ky114

本文主要是介绍KY114 Coincidence,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

最长非连续子串长度,自己扣了半天,没写准,看了题解恍然大明白
ti

#include<bits/stdc++.h>using namespace std;int n, m, c;
int p[1000010], q[1000010], k[2000010];
string s1, s2;
map<char, int>mp;
int dp[110][110]; 
int d[110]; bool cpdd(char a, char b){if(a == b) return 1;return 0;
}int main() {while (cin >> s1 >> s2) {  //非连续最长公共子序列 memset(dp, 0, sizeof dp);int len1 = s1.length();int len2 = s2.length();for(int i = 1; i <= len1; i ++ ){for(int j = 1; j <= len2; 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]);}}} cout<< dp[len1][len2] << endl;}return 0;
}

这篇关于KY114 Coincidence的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/685357

相关文章

Coincidence(LCS最长公共子序列)

题目1042:Coincidence 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:810 解决:430 题目描述: Find a longest common subsequence of two strings. 输入: First and second line of each input case contain two strings of

九度oj-1042-Coincidence

时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2338 解决:1255 题目描述: Find a longest common subsequence of two strings. 输入: First and second line of each input case contain two strings of lowercase charac

九度OJ 1042:Coincidence(公共子序列) (DP)

时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2303 解决:1241 题目描述: Find a longest common subsequence of two strings. 输入: First and second line of each input case contain two strings of lowercase char

Coincidence (九度教程第98题) 最长公共子序列(LCS) 动态规划

Find a longest common subsequence of two strings. 输入描述: First and second line of each input case contain two strings of lowercase character a…z. There are no spaces before, inside or after the string