From edf59c0a90759a2f929bc488a8d22fa6003c26a8 Mon Sep 17 00:00:00 2001 From: JHLEE325 <82587652+JHLEE325@users.noreply.github.com> Date: Mon, 15 Dec 2025 21:24:00 +0900 Subject: [PATCH] =?UTF-8?q?[20251215]=20BOJ=20/=20G5=20/=20=EB=84=B4?= =?UTF-8?q?=EB=AA=A8=EB=84=B4=EB=AA=A8=20(Easy)=20/=20=EC=9D=B4=EC=A4=80?= =?UTF-8?q?=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...252\250\353\204\264\353\252\250 (Easy).md" | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 "JHLEE325/202512/15 BOJ G5 \353\204\264\353\252\250\353\204\264\353\252\250 (Easy).md" diff --git "a/JHLEE325/202512/15 BOJ G5 \353\204\264\353\252\250\353\204\264\353\252\250 (Easy).md" "b/JHLEE325/202512/15 BOJ G5 \353\204\264\353\252\250\353\204\264\353\252\250 (Easy).md" new file mode 100644 index 00000000..38b591bc --- /dev/null +++ "b/JHLEE325/202512/15 BOJ G5 \353\204\264\353\252\250\353\204\264\353\252\250 (Easy).md" @@ -0,0 +1,60 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + + static int N, M; + static boolean[][] map; + static int answer = 0; + + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + N = Integer.parseInt(st.nextToken()); + M = Integer.parseInt(st.nextToken()); + + map = new boolean[N][M]; + + dfs(0, 0); + + System.out.println(answer); + } + + static void dfs(int r, int c) { + if (r == N) { + answer++; + return; + } + + int nr = r; + int nc = c + 1; + if (nc == M) { + nr = r + 1; + nc = 0; + } + + dfs(nr, nc); + + map[r][c] = true; + + if (!hasFull2x2()) { + dfs(nr, nc); + } + + map[r][c] = false; + } + + static boolean hasFull2x2() { + for (int i = 0; i < N - 1; i++) { + for (int j = 0; j < M - 1; j++) { + if (map[i][j] && map[i + 1][j] && map[i][j + 1] && map[i + 1][j + 1]) { + return true; + } + } + } + return false; + } +} +```