From a570f4443b18c10112c7a8565fce3672cabdfe53 Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Fri, 8 Aug 2025 22:11:17 +0900 Subject: [PATCH] =?UTF-8?q?[20250808]=20BOJ=20/=20G4=20/=20=EA=B0=80?= =?UTF-8?q?=EC=9E=A5=20=ED=81=B0=20=EC=A0=95=EC=82=AC=EA=B0=81=ED=98=95=20?= =?UTF-8?q?/=20=EC=9D=B4=EC=A2=85=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...25\354\202\254\352\260\201\355\230\225.md" | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 "0224LJH/202508/8 BOJ \352\260\200\354\236\245 \355\201\260 \354\240\225\354\202\254\352\260\201\355\230\225.md" diff --git "a/0224LJH/202508/8 BOJ \352\260\200\354\236\245 \355\201\260 \354\240\225\354\202\254\352\260\201\355\230\225.md" "b/0224LJH/202508/8 BOJ \352\260\200\354\236\245 \355\201\260 \354\240\225\354\202\254\352\260\201\355\230\225.md" new file mode 100644 index 00000000..7e930b27 --- /dev/null +++ "b/0224LJH/202508/8 BOJ \352\260\200\354\236\245 \355\201\260 \354\240\225\354\202\254\352\260\201\355\230\225.md" @@ -0,0 +1,60 @@ +```java +import java.awt.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.*; + +public class Main { + static int height, width; + static int[][] arr; + static int[][] dp; + + public static void main(String[] args) throws IOException { + init(); + int result = process(); + System.out.println(result * result); + } + + private static void init() throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + height = Integer.parseInt(st.nextToken()); + width = Integer.parseInt(st.nextToken()); + + arr = new int[height][width]; + dp = new int[height][width]; + + for (int i = 0; i < height; i++) { + String[] input = br.readLine().split(""); + for (int j = 0; j < width; j++) { + arr[i][j] = Integer.parseInt(input[j]); + } + } + } + + private static int process() { + int maxSize = 0; + + // DP 초기화 및 계산 + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + if (arr[i][j] == 1) { + if (i == 0 || j == 0) { + dp[i][j] = 1; + } else { + // 왼쪽, 위쪽, 대각선 위쪽의 최솟값 + 1 + dp[i][j] = Math.min(dp[i-1][j], + Math.min(dp[i][j-1], dp[i-1][j-1])) + 1; + } + maxSize = Math.max(maxSize, dp[i][j]); + } else { + dp[i][j] = 0; + } + } + } + + return maxSize; + } +} +``` \ No newline at end of file