From 138376b86c5e63f1baf1c939e9f833ede13b2012 Mon Sep 17 00:00:00 2001 From: oncsr Date: Sat, 6 Sep 2025 17:14:52 +0900 Subject: [PATCH] =?UTF-8?q?[20250906]=20BOJ=20/=20G2=20/=20=EB=A9=80?= =?UTF-8?q?=EC=A7=80=EB=A7=8C=20=EA=B0=80=EA=B9=8C=EC=9A=B4=20=EC=82=AC?= =?UTF-8?q?=EC=9D=B4=20/=20=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\354\232\264 \354\202\254\354\235\264.md" | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 "khj20006/202509/06 BOJ G2 \353\251\200\354\247\200\353\247\214 \352\260\200\352\271\214\354\232\264 \354\202\254\354\235\264.md" diff --git "a/khj20006/202509/06 BOJ G2 \353\251\200\354\247\200\353\247\214 \352\260\200\352\271\214\354\232\264 \354\202\254\354\235\264.md" "b/khj20006/202509/06 BOJ G2 \353\251\200\354\247\200\353\247\214 \352\260\200\352\271\214\354\232\264 \354\202\254\354\235\264.md" new file mode 100644 index 00000000..4d4aef08 --- /dev/null +++ "b/khj20006/202509/06 BOJ G2 \353\251\200\354\247\200\353\247\214 \352\260\200\352\271\214\354\232\264 \354\202\254\354\235\264.md" @@ -0,0 +1,111 @@ +```java +import java.util.*; +import java.io.*; + +class IOController { + BufferedReader br; + BufferedWriter bw; + StringTokenizer st; + + public IOController() { + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + st = new StringTokenizer(""); + } + + String nextLine() throws Exception { + String line = br.readLine(); + st = new StringTokenizer(line); + return line; + } + + String nextToken() throws Exception { + while (!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + + int nextInt() throws Exception { + return Integer.parseInt(nextToken()); + } + + long nextLong() throws Exception { + return Long.parseLong(nextToken()); + } + + double nextDouble() throws Exception { + return Double.parseDouble(nextToken()); + } + + void close() throws Exception { + bw.flush(); + bw.close(); + } + + void write(String content) throws Exception { + bw.write(content); + } + +} + +public class Main { + + static IOController io; + + // + + static int N; + static List[] graph; + static List list; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + N = io.nextInt(); + list = new ArrayList<>(); + graph = new List[N+1]; + for(int i=1;i<=N;i++) graph[i] = new ArrayList<>(); + for(int i=1;i q = new ArrayDeque<>(); + boolean[] vis = new boolean[N+1]; + q.offer(new int[]{1,0}); + vis[1] = true; + while(!q.isEmpty()) { + int[] cur = q.poll(); + int n = cur[0], v = cur[1]; + list.add(v); + for(int[] e:graph[n]) if(!vis[e[0]]) { + vis[e[0]] = true; + q.offer(new int[]{e[0],v^e[1]}); + } + } + Collections.sort(list); + + long ans = 0, cnt = 1; + int prev = list.get(0); + for(int i=1;i