水………………………………………………………………………………过,只不过是加个判断和模板无分别
#include<iostream>
#include<string>
#include<vector>
using namespace std;
string a,b;
string Lcs(){
vector<int> s(a.size(),0);
string::size_type i = 1,j = 1;
int flag = s[0]; int flag2 = s[0];
while(j < b.size()){
for(i = 1;i < a.size();i++){
int temp = s[i];
if(a[i] == b[j])
s[i] = flag2+1;
else{
s[i] = flag > s[i]? flag:s[i];
}
flag2 = temp;
flag = s[i];
}
j++;
flag = flag2 = s[0];
}
if(s[a.size()-1] == a.size()-1)
return "Yes";
else
return "No";
}
int main()
{
while(cin >>a >>b){
a = " "+a; b = " "+b;
cout <<Lcs() <<endl;
}
return 0;
}