Skip to content

Commit

Permalink
Create 9251.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
encrypted-def authored Jan 5, 2025
1 parent ba3b2fb commit 5368bfd
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Appendix E/9251.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// http://boj.kr/cf49db3b3f394eb192a482da5f7a8f84
#include <bits/stdc++.h>
using namespace std;

string a, b;
int n, m;
int d[1005][1005];

int main() {
ios::sync_with_stdio(0);
cin.tie(0);

cin >> a >> b;
n = a.size();
m = b.size();

for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(a[i-1] == b[j-1])
d[i][j] = d[i-1][j-1] + 1;
d[i][j] = max({d[i][j], d[i-1][j], d[i][j-1]});
}
}
cout << d[n][m];
}

0 comments on commit 5368bfd

Please sign in to comment.