From 5368bfd964e5c772b2f4f00d2c017d28b193b4d4 Mon Sep 17 00:00:00 2001 From: encrypted-def <20028331+encrypted-def@users.noreply.github.com> Date: Sun, 5 Jan 2025 21:02:01 +0900 Subject: [PATCH] Create 9251.cpp --- Appendix E/9251.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Appendix E/9251.cpp diff --git a/Appendix E/9251.cpp b/Appendix E/9251.cpp new file mode 100644 index 00000000..c11aaab5 --- /dev/null +++ b/Appendix E/9251.cpp @@ -0,0 +1,25 @@ +// http://boj.kr/cf49db3b3f394eb192a482da5f7a8f84 +#include +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]; +}