Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("lungimesubsircomunmaximal.in");
- ofstream fout("lungimesubsircomunmaximal.out");
- int n,m,LCS[1005][1005];
- char a[1005],b[1005];
- void pd()
- {
- for(int i=1;i<=n;i++)
- for(int j=1;j<=m;j++)
- if(a[i]==b[j])
- LCS[i][j]=1+LCS[i-1][j-1];
- else
- LCS[i][j]=max(LCS[i-1][j-1],max(LCS[i-1][j],LCS[i][j-1]));
- fout<<LCS[n][m];
- }
- int main()
- {
- fin.getline(a+1,1005);
- fin.getline(b+1,1005);
- n=strlen(a+1);
- m=strlen(b+1);
- pd();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement