Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- ///****************
- #define NMAX 1001
- char a[NMAX], b[NMAX];
- int dp[NMAX][NMAX];
- int getLCSSlen(char a[], char b[]) {
- int n = strlen(a + 1);
- int m = strlen(b + 1);
- int ans = 0;
- assert(n < NMAX && m < NMAX);
- for (int i = 1; i <= n; i++)
- for (int j = 1; j <= m; j++)
- if (a[i] == b[j]) {
- dp[i][j] = dp[i - 1][j - 1] + 1;//else =0;
- ans = max(ans, dp[i][j]);
- }
- return ans;
- }
- int main() {
- cin >> (a + 1) >> (b + 1);
- std::cerr << getLCSSlen(a, b) << '\n';//9
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement