From 5813087056d3c2b88d42371d9342e20d972f65d0 Mon Sep 17 00:00:00 2001 From: JHLEE325 <82587652+JHLEE325@users.noreply.github.com> Date: Tue, 30 Sep 2025 23:41:27 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[20250930]=20BOJ=20/=20G4=20/=20=EB=AE=A4?= =?UTF-8?q?=ED=83=88=EB=A6=AC=EC=8A=A4=ED=81=AC=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 --- ...10\353\246\254\354\212\244\355\201\254.md" | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 "JHLEE325/20250930 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" diff --git "a/JHLEE325/20250930 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" "b/JHLEE325/20250930 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" new file mode 100644 index 00000000..d9572e2e --- /dev/null +++ "b/JHLEE325/20250930 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" @@ -0,0 +1,67 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + static class State { + int a, b, c, cnt; + State(int a, int b, int c, int cnt) { + this.a = a; + this.b = b; + this.c = c; + this.cnt = cnt; + } + } + + static int[] dmg = {9, 3, 1}; + static boolean[][][] visited = new boolean[61][61][61]; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int n = Integer.parseInt(br.readLine()); + + int[] scv = new int[3]; + StringTokenizer st = new StringTokenizer(br.readLine()); + for (int i = 0; i < n; i++) { + scv[i] = Integer.parseInt(st.nextToken()); + } + + System.out.println(bfs(scv[0], scv[1], scv[2])); + } + + static int bfs(int a, int b, int c) { + Queue q = new LinkedList<>(); + q.add(new State(a, b, c, 0)); + visited[a][b][c] = true; + + while (!q.isEmpty()) { + State cur = q.poll(); + int x = cur.a; + int y = cur.b; + int z = cur.c; + + if (x == 0 && y == 0 && z == 0) { + return cur.cnt; + } + + int[][] orders = { + {0,1,2}, {0,2,1}, + {1,0,2}, {1,2,0}, + {2,0,1}, {2,1,0} + }; + + for (int[] ord : orders) { + int nx = Math.max(0, x - dmg[ord[0]]); + int ny = Math.max(0, y - dmg[ord[1]]); + int nz = Math.max(0, z - dmg[ord[2]]); + + if (!visited[nx][ny][nz]) { + visited[nx][ny][nz] = true; + q.add(new State(nx, ny, nz, cur.cnt + 1)); + } + } + } + return -1; + } +} +``` From bb23518df45b1d309a5071a64ae9dfff1ea12ddd Mon Sep 17 00:00:00 2001 From: JHLEE325 <82587652+JHLEE325@users.noreply.github.com> Date: Tue, 30 Sep 2025 23:42:44 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[20250930]=20BOJ=20/=20G4=20/=20=EB=AE=A4?= =?UTF-8?q?=ED=83=88=EB=A6=AC=EC=8A=A4=ED=81=AC=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 --- ...53\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "JHLEE325/20250930 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" => "JHLEE325/202509/20250930 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" (100%) diff --git "a/JHLEE325/20250930 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" "b/JHLEE325/202509/20250930 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" similarity index 100% rename from "JHLEE325/20250930 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" rename to "JHLEE325/202509/20250930 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" From 49bdb10b45963b6439269ad32b7fa9e20147501c Mon Sep 17 00:00:00 2001 From: JHLEE325 <82587652+JHLEE325@users.noreply.github.com> Date: Tue, 30 Sep 2025 23:43:34 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[20250930]=20BOJ=20/=20G4=20/=20=EB=AE=A4?= =?UTF-8?q?=ED=83=88=EB=A6=AC=EC=8A=A4=ED=81=AC=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 --- ...53\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "JHLEE325/202509/20250930 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" => "JHLEE325/202509/30 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" (100%) diff --git "a/JHLEE325/202509/20250930 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" "b/JHLEE325/202509/30 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" similarity index 100% rename from "JHLEE325/202509/20250930 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md" rename to "JHLEE325/202509/30 BOJ G4 \353\256\244\355\203\210\353\246\254\354\212\244\355\201\254.md"