From 4018aa420d9afc42280096bad099106c93478c1b Mon Sep 17 00:00:00 2001 From: oncsr Date: Thu, 20 Mar 2025 11:16:20 +0900 Subject: [PATCH] =?UTF-8?q?[20250320]=20BOJ=20/=20G3=20/=20=EB=93=B1?= =?UTF-8?q?=EC=88=98=20=EC=B0=BE=EA=B8=B0=20/=20=EA=B6=8C=ED=98=81?= =?UTF-8?q?=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...1\354\210\230 \354\260\276\352\270\260.md" | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 "khj20006/202503/20 BOJ G3 \353\223\261\354\210\230 \354\260\276\352\270\260.md" diff --git "a/khj20006/202503/20 BOJ G3 \353\223\261\354\210\230 \354\260\276\352\270\260.md" "b/khj20006/202503/20 BOJ G3 \353\223\261\354\210\230 \354\260\276\352\270\260.md" new file mode 100644 index 00000000..1712e70c --- /dev/null +++ "b/khj20006/202503/20 BOJ G3 \353\223\261\354\210\230 \354\260\276\352\270\260.md" @@ -0,0 +1,77 @@ +```java + +import java.util.*; +import java.io.*; + +class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st = new StringTokenizer(""); + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static String nextToken() throws Exception { + if(!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + static int nextInt() throws Exception { return Integer.parseInt(nextToken()); } + static long nextLong() throws Exception { return Long.parseLong(nextToken()); } + static double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static int N, M, X; + static List[] V, E; + static boolean[] vis; + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = nextInt(); + M = nextInt(); + X = nextInt(); + V = new List[N+1]; + E = new List[N+1]; + for(int i=1;i<=N;i++) { + V[i] = new ArrayList<>(); + E[i] = new ArrayList<>(); + } + for(int i=0;i[] G, int n) { + int res = 0; + for(int i:G[n]) if(!vis[i]) { + vis[i] = true; + res += dfs(G,i); + } + return res+1; + } + +} + +```