From 663f86670385b582c54b81bd9c6031794b8b772f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=A7=84?= Date: Thu, 30 Oct 2025 12:23:39 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[20251030]=20BOJ=20/=20G4=20/=20=EB=B9=A0?= =?UTF-8?q?=EB=A5=B8=20=EB=AC=B4=EC=9E=91=EC=9C=84=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=20=EC=A0=84=EB=8B=AC=20/=20=EA=B9=80=EB=AF=BC?= =?UTF-8?q?=EC=A7=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\354\247\200 \354\240\204\353\213\254.md" | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 "zinnnn37/202510/30 BOJ G4 \353\271\240\353\245\270 \353\254\264\354\236\221\354\234\204 \353\251\224\354\213\234\354\247\200 \354\240\204\353\213\254.md" diff --git "a/zinnnn37/202510/30 BOJ G4 \353\271\240\353\245\270 \353\254\264\354\236\221\354\234\204 \353\251\224\354\213\234\354\247\200 \354\240\204\353\213\254.md" "b/zinnnn37/202510/30 BOJ G4 \353\271\240\353\245\270 \353\254\264\354\236\221\354\234\204 \353\251\224\354\213\234\354\247\200 \354\240\204\353\213\254.md" new file mode 100644 index 00000000..e7df1172 --- /dev/null +++ "b/zinnnn37/202510/30 BOJ G4 \353\271\240\353\245\270 \353\254\264\354\236\221\354\234\204 \353\251\224\354\213\234\354\247\200 \354\240\204\353\213\254.md" @@ -0,0 +1,68 @@ +```java +import java.io.*; +import java.util.StringTokenizer; + +public class BJ_25835_빠른_무작위_메시지_전달 { + + private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + private static StringTokenizer st; + + private static long ans; + private static int[][] friends; + private static boolean[] visited; + + public static void main(String[] args) throws IOException { + init(); + sol(); + + bw.write(ans + ""); + bw.flush(); + bw.close(); + br.close(); + } + + private static void init() throws IOException { + ans = Long.MAX_VALUE; + + friends = new int[12][12]; + for (int i = 0; i < 12; i++) { + st = new StringTokenizer(br.readLine()); + for (int j = 0; j < 12; j++) { + friends[i][j] = Integer.parseInt(st.nextToken()); + } + } + visited = new boolean[6]; + } + + private static void sol() throws IOException { + for (int nextGroup = 0; nextGroup < 6; nextGroup++) { + int next = nextGroup * 2; + + visited[nextGroup] = true; + dfs(1, next + 1, friends[next][next + 1]); + dfs(1, next, friends[next + 1][next]); + visited[nextGroup] = false; + } + } + + private static void dfs(int depth, int cur, long sum) throws IOException { + if (depth == 6) { + ans = Math.min(ans, sum); + return; + } + + for (int i = 0; i < 6; i++) { + if (visited[i]) continue; + + int next = i * 2; + + visited[i] = true; + dfs(depth + 1, next, sum + friends[cur][next + 1] + friends[next + 1][next]); + dfs(depth + 1, next + 1, sum + friends[cur][next] + friends[next][next + 1]); + visited[i] = false; + } + } + +} +``` \ No newline at end of file From 35fb7ae5c35d90cf11b9c8ed453b4953b464edca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=A7=84?= Date: Thu, 30 Oct 2025 12:26:13 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[20251030]=20BOJ=20/=20G4=20/=20=EB=B9=A0?= =?UTF-8?q?=EB=A5=B8=20=EB=AC=B4=EC=9E=91=EC=9C=84=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=20=EC=A0=84=EB=8B=AC=20/=20=EA=B9=80=EB=AF=BC?= =?UTF-8?q?=EC=A7=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...224\354\213\234\354\247\200 \354\240\204\353\213\254.md" | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git "a/zinnnn37/202510/30 BOJ G4 \353\271\240\353\245\270 \353\254\264\354\236\221\354\234\204 \353\251\224\354\213\234\354\247\200 \354\240\204\353\213\254.md" "b/zinnnn37/202510/30 BOJ G4 \353\271\240\353\245\270 \353\254\264\354\236\221\354\234\204 \353\251\224\354\213\234\354\247\200 \354\240\204\353\213\254.md" index e7df1172..bacef00a 100644 --- "a/zinnnn37/202510/30 BOJ G4 \353\271\240\353\245\270 \353\254\264\354\236\221\354\234\204 \353\251\224\354\213\234\354\247\200 \354\240\204\353\213\254.md" +++ "b/zinnnn37/202510/30 BOJ G4 \353\271\240\353\245\270 \353\254\264\354\236\221\354\234\204 \353\251\224\354\213\234\354\247\200 \354\240\204\353\213\254.md" @@ -8,7 +8,7 @@ public class BJ_25835_빠른_무작위_메시지_전달 { private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); private static StringTokenizer st; - private static long ans; + private static int ans; private static int[][] friends; private static boolean[] visited; @@ -23,7 +23,7 @@ public class BJ_25835_빠른_무작위_메시지_전달 { } private static void init() throws IOException { - ans = Long.MAX_VALUE; + ans = Integer.MAX_VALUE; friends = new int[12][12]; for (int i = 0; i < 12; i++) { @@ -46,7 +46,7 @@ public class BJ_25835_빠른_무작위_메시지_전달 { } } - private static void dfs(int depth, int cur, long sum) throws IOException { + private static void dfs(int depth, int cur, int sum) throws IOException { if (depth == 6) { ans = Math.min(ans, sum); return;