From 71fd2ac75b14ff3170fb18991795b39a0e1ba3f4 Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Thu, 10 Jul 2025 13:52:34 +0900 Subject: [PATCH 1/3] Create .gitkeep --- 0224LJH/202507/.gitkeep | 1 + 1 file changed, 1 insertion(+) create mode 100644 0224LJH/202507/.gitkeep diff --git a/0224LJH/202507/.gitkeep b/0224LJH/202507/.gitkeep new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/0224LJH/202507/.gitkeep @@ -0,0 +1 @@ + From 81fbeb158f91bc2e50bc03c4f8d3163d4eb507bc Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Thu, 10 Jul 2025 14:14:47 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[20250710]=20BOJ=20/=20G2=20/=20=EA=B6=81?= =?UTF-8?q?=EA=B8=88=ED=95=9C=20=EB=AF=BC=ED=98=B8=20/=20=EC=9D=B4?= =?UTF-8?q?=EC=A2=85=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\355\225\234 \353\257\274\355\230\270.md" | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 "0224LJH/202507/10 BOJ \352\266\201\352\270\210\355\225\234 \353\257\274\355\230\270.md" diff --git "a/0224LJH/202507/10 BOJ \352\266\201\352\270\210\355\225\234 \353\257\274\355\230\270.md" "b/0224LJH/202507/10 BOJ \352\266\201\352\270\210\355\225\234 \353\257\274\355\230\270.md" new file mode 100644 index 00000000..95eafbe3 --- /dev/null +++ "b/0224LJH/202507/10 BOJ \352\266\201\352\270\210\355\225\234 \353\257\274\355\230\270.md" @@ -0,0 +1,69 @@ + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.*; + +public class Main { +static int cityCnt, ans; +static int[][] distance; + + public static void main(String[] args) throws IOException { + init(); + process(); + print(); + } + + private static void init() throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + cityCnt = Integer.parseInt(br.readLine()); + distance = new int[cityCnt][cityCnt]; + ans = 0; + + for (int i = 0; i < cityCnt; i++){ + StringTokenizer st = new StringTokenizer(br.readLine()); + for (int j = 0; j < cityCnt; j++){ + distance[i][j] = Integer.parseInt(st.nextToken()); + } + } + } + + private static void process() { + for (int i = 0; i < cityCnt; i++){ + for (int j = i; j < cityCnt; j++){ + if ( i == j) continue; + if (distance[i][j] != distance[j][i]){ + // i->j와 j->i는 같아야함 + ans = -1; + return; + } + + boolean isDirectlyConnected = true; + + for (int k = 0; k < cityCnt; k++){ + if ( i == k || j ==k) continue; + int tempDis = distance[i][k] + distance[k][j]; + + if (tempDis < distance[i][j]){ + //지금 명시된 길이가 두개의 길을 이은것 보다 짧음 -> 불가능 + ans =-1; + return; + } else if ( tempDis== distance[i][j]) { + isDirectlyConnected = false; + break; + } + } + + if (isDirectlyConnected) { + ans += distance[i][j]; + } + } + } + } + + + + private static void print() { + System.out.print(ans); + } +} \ No newline at end of file From 1d90c50fdf534844e80a6f7d74916beaadc06207 Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Thu, 10 Jul 2025 14:27:43 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[20250710]=20BOJ=20/=20G2=20/=20=EA=B6=81?= =?UTF-8?q?=EA=B8=88=ED=95=9C=20=EB=AF=BC=ED=98=B8=20/=20=EC=9D=B4?= =?UTF-8?q?=EC=A2=85=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\201\352\270\210\355\225\234 \353\257\274\355\230\270.md" | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git "a/0224LJH/202507/10 BOJ \352\266\201\352\270\210\355\225\234 \353\257\274\355\230\270.md" "b/0224LJH/202507/10 BOJ \352\266\201\352\270\210\355\225\234 \353\257\274\355\230\270.md" index 95eafbe3..cdcc7fc7 100644 --- "a/0224LJH/202507/10 BOJ \352\266\201\352\270\210\355\225\234 \353\257\274\355\230\270.md" +++ "b/0224LJH/202507/10 BOJ \352\266\201\352\270\210\355\225\234 \353\257\274\355\230\270.md" @@ -1,4 +1,4 @@ - +```java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -66,4 +66,5 @@ static int[][] distance; private static void print() { System.out.print(ans); } -} \ No newline at end of file +} +```