9521
[골5] 9251 - LCS
#include #include #include using namespace std; int main() { string str1, str2; cin >> str1 >> str2; str1 = ' ' + str1; str2 = ' ' + str2; int n = str1.size(), m = str2.size(); vector v(n, vector(m)); for (int i = 1; i < n; i++) { for (int j = 1; j < m; j++) { if (str1[i] == str2[j]) v[i][j] = v[i - 1][j - 1] + 1; else v[i][j] = max(v[i - 1][j], v[i][j - 1]); } } cout