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; + } + +} + +```