From 871761fd97175c148a4f8e74eb13fc25b546bfad Mon Sep 17 00:00:00 2001 From: dk7648 <76927860+dk7648@users.noreply.github.com> Date: Mon, 9 Dec 2024 19:56:04 +0900 Subject: [PATCH] =?UTF-8?q?complete=20[W6]=20=EA=B0=80=EC=9E=A5=20?= =?UTF-8?q?=ED=81=B0=20=EC=A0=95=EC=82=AC=EA=B0=81=ED=98=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- week6/KBC/boj_1915.java | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 week6/KBC/boj_1915.java diff --git a/week6/KBC/boj_1915.java b/week6/KBC/boj_1915.java new file mode 100644 index 0000000..0068b2d --- /dev/null +++ b/week6/KBC/boj_1915.java @@ -0,0 +1,34 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class Main { + static int height; + static int width; + static int[][] map; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + String[] input = br.readLine().split(" "); + height = Integer.parseInt(input[0]); + width = Integer.parseInt(input[1]); + map = new int[height + 1][width + 1]; + for (int h = 1; h <= height; h++) { + input = br.readLine().split(""); + for (int w = 1; w <= width; w++) { + map[h][w] = Integer.parseInt(input[w - 1]); + } + } + + int max = 0; + for (int h = 1; h <= height; h++) { + for (int w = 1; w <= width; w++) { + if (map[h][w] >= 1 && map[h][w - 1] >= 1 && map[h - 1][w] >= 1 && map[h - 1][w - 1] >= 1) { + map[h][w] = Math.min(map[h][w - 1], Math.min(map[h - 1][w], map[h-1][w-1])) + 1; + } + max = Math.max(map[h][w], max); + } + } + System.out.println(max * max); + } +}