1 条题解
-
1
#include<bits/stdc++.h> using namespace std; int dp[1010][1010]; int main(){ freopen("lcs.in", "r", stdin); freopen("lcs.out", "w", stdout); string a , b; cin >> a >> b; int x = a.size() , y = b.size(); for (int i = 1;i <= x;i++){ for (int j = 1;j <= y;j++){ if (a[i - 1] == b[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[x][y] << endl; return 0; }
- 1
信息
- ID
- 492
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 5
- 标签
- (无)
- 递交数
- 94
- 已通过
- 33
- 上传者