From 08e90bac059f773223e3ce1886532b8b919f8e0e Mon Sep 17 00:00:00 2001 From: JHLEE325 <82587652+JHLEE325@users.noreply.github.com> Date: Mon, 14 Jul 2025 13:22:20 +0900 Subject: [PATCH] =?UTF-8?q?[20250714]=20BOJ=20/=20G4=20/=20=EC=A0=80?= =?UTF-8?q?=EC=9A=B8=20/=20=EC=9D=B4=EC=A4=80=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../14 BOJ G4 \354\240\200\354\232\270.md" | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 "JHLEE325/202507/14 BOJ G4 \354\240\200\354\232\270.md" diff --git "a/JHLEE325/202507/14 BOJ G4 \354\240\200\354\232\270.md" "b/JHLEE325/202507/14 BOJ G4 \354\240\200\354\232\270.md" new file mode 100644 index 00000000..62806884 --- /dev/null +++ "b/JHLEE325/202507/14 BOJ G4 \354\240\200\354\232\270.md" @@ -0,0 +1,51 @@ +```java +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayDeque; +import java.util.Queue; +import java.util.StringTokenizer; + +public class Main { + static Queue list = new ArrayDeque<>(); + static int n, m; + static int[][] w; + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + n = Integer.parseInt(br.readLine()); + m = Integer.parseInt(br.readLine()); + + w = new int[n][n]; + + for (int i = 0; i < m; i++) { + st = new StringTokenizer(br.readLine()); + int big = Integer.parseInt(st.nextToken()) - 1; + int small = Integer.parseInt(st.nextToken()) - 1; + w[big][small] = 1; + w[small][big] = 2; + } + + for (int k = 0; k < n; k++) { + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (w[i][k] == 1 && w[k][j] == 1) w[i][j] = 1; + if (w[i][k] == 2 && w[k][j] == 2) w[i][j] = 2; + } + } + } + + for (int i = 0; i < n; i++) { + int count = 0; + for (int j = 0; j < n; j++) { + if (i != j && w[i][j] == 0) count++; + } + System.out.println(count); + } + } + + +} +```