For example, Z = < a, b, f, c > is a subsequence of X = < a, b, c, f, b, c > with index sequence < 1, 2, 4, 6 >. Given two sequences X and Y the problem is to find the length of the maximum-length common subsequence of X and Y. InputThe program input is from...
DP。。。 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; char a[305],b[305]; int f[305][305]; int main() { while(scanf("%s%s",a,b)!=EOF){ int alen=strlen(a); int blen=strlen(b); for(int i=1;i<=alen;i++) for(int j=1;j<=blen;j++...
代码: #include<cstdio>#include<cstring>#include<iostream>#include<string>#include<algorithm>usingnamespacestd;constintMAXN=3e2+10;constintINF=0x3f3f3f3f;chars[MAXN];chart[MAXN];intdp[MAXN][MAXN];voidLCS(intlen1,intlen2){for(inti=0;i<len1;++i){for(intj=0;j<len2;++j){if(s[...
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <algorithm>6#include <vector>7#include <queue>8#include <stack>9#include 10#include <string>11#include <set>12#definems(a,b) memset((a),(b),sizeof((a)))13usingnamespacestd;14typedeflonglongLL;15...