diff --git a/hoonti06/BOJ/11000/11403/Main.java b/hoonti06/BOJ/11000/11403/Main.java new file mode 100644 index 0000000..9c981d0 --- /dev/null +++ b/hoonti06/BOJ/11000/11403/Main.java @@ -0,0 +1,42 @@ +import java.io.*; +import java.util.*; + +public class Main { + static int N; + static int[][] edge; + + static void solution() { + for (int k = 0; k < N; k++) { + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (edge[i][k] == 0 || edge[k][j] == 0) + continue; + + edge[i][j] = 1; + } + } + } + } + public static void main(String[] args) throws Exception { + BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); + + N = Integer.parseInt(in.readLine()); + edge = new int[N][N]; + for (int i = 0; i < N; i++) { + StringTokenizer st = new StringTokenizer(in.readLine(), " "); + for (int j = 0; j < N; j++) + edge[i][j] = Integer.parseInt(st.nextToken()); + } + + solution(); + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) + sb.append(edge[i][j]).append(" "); + sb.append("\n"); + } + System.out.print(sb); + } +} + diff --git a/hoonti06/BOJ/11000/11403/README.md b/hoonti06/BOJ/11000/11403/README.md new file mode 100644 index 0000000..22749d0 --- /dev/null +++ b/hoonti06/BOJ/11000/11403/README.md @@ -0,0 +1,23 @@ +## ๐Ÿ…ฐ ์„ค๊ณ„ + +* floyd-warshall ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ํ™œ์šฉํ•˜์—ฌ ๊ฒฝ์œ ์ง€ k๋ฅผ ๊ฑฐ์ณ i์—์„œ j๊นŒ์ง€ ๊ฐˆ ์ˆ˜ ์žˆ๋Š” ์ง€๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. + +```java +for (int k = 0; k < N; k++) { + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + if (edge[i][k] == 0 || edge[k][j] == 0) + continue; + + edge[i][j] = 1; + } + } +} +``` + + + +## โœ… ํ›„๊ธฐ + +- ์Œค์—๊ฒŒ ๋ฐฐ์šด ๊ฒฝ์ถœ๋„๋ฅผ ์ ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. +- 3์ค‘ for๋ฌธ์˜ ์ •ํ™•ํ•œ ์ž‘์šฉ ๋ฐฉ์‹์ด ๊ธฐ์–ต์ด ๋‚˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.