From 6c0b4cc652bccd7d2372895f33c26fa183abbf76 Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Thu, 27 Nov 2025 10:38:13 +0900 Subject: [PATCH] =?UTF-8?q?[20251127]=20BOj=20/=20G4=20/=20LCS=20/=20?= =?UTF-8?q?=EC=9D=B4=EC=A2=85=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 0224LJH/202511/27 BOJ LCS3.md | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 0224LJH/202511/27 BOJ LCS3.md diff --git a/0224LJH/202511/27 BOJ LCS3.md b/0224LJH/202511/27 BOJ LCS3.md new file mode 100644 index 00000000..bf83f039 --- /dev/null +++ b/0224LJH/202511/27 BOJ LCS3.md @@ -0,0 +1,52 @@ +```java +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.HashSet; +import java.util.StringTokenizer; + +public class Main { + + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static char[][] words; + static int[][][] dp; + static int ans = 0; + + + public static void main(String[] args) throws IOException { + + init(); + process(); + print(); + + } + + private static void init() throws IOException{ + words = new char[3][]; + for (int i = 0; i < 3; i++) { + words[i] = br.readLine().toCharArray(); + } + dp = new int[words[0].length+1][words[1].length+1][words[2].length+1]; + } + + private static void process() throws IOException { + for (int i = 1; i <= words[0].length; i++) { + for (int j = 1; j <= words[1].length; j++) { + for (int k = 1; k <= words[2].length; k++) { + if (words[0][i-1] == words[1][j-1] && words[1][j-1] == words[2][k-1]) { + dp[i][j][k] = dp[i-1][j-1][k-1]+1; + } else { + dp[i][j][k] =Math.max(Math.max(dp[i-1][j][k], dp[i][j-1][k]), dp[i][j][k-1]); + } + } + } + } + } + + private static void print() { + System.out.println(dp[words[0].length][words[1].length][words[2].length]); + } + +} +```