From 5226ef5c3ffca1235a6692f329a2bb8d09d718cb Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Fri, 23 Jan 2026 22:38:46 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[20260123]=20BOJ=20/=20G4=20/=20=ED=8A=B8?= =?UTF-8?q?=EB=A6=AC=20=EC=88=9C=ED=9A=8C=20/=20=EC=9D=B4=EC=9D=B8?= =?UTF-8?q?=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\270\353\246\254 \354\210\234\355\232\214" | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 "LiiNi-coder/202601/23 BOJ \355\212\270\353\246\254 \354\210\234\355\232\214" diff --git "a/LiiNi-coder/202601/23 BOJ \355\212\270\353\246\254 \354\210\234\355\232\214" "b/LiiNi-coder/202601/23 BOJ \355\212\270\353\246\254 \354\210\234\355\232\214" new file mode 100644 index 00000000..e9570cbd --- /dev/null +++ "b/LiiNi-coder/202601/23 BOJ \355\212\270\353\246\254 \354\210\234\355\232\214" @@ -0,0 +1,90 @@ +```java +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.HashMap; +import java.util.Map; + +public class Main{ + + private static class Node{ + int value; + Node c1; + Node c2; + public Node(int v){ + this.value = v; + c1 = c2 = null; + } + } + private static Map Nodes; + private static long answer = 0; + private static Deque q = new ArrayDeque<>(); + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int n = Integer.parseInt(br.readLine()); + int t = n; + Nodes = new HashMap<>(); + Nodes.put(1, new Node(1)); + while(t-->0){ + String[] tokens = br.readLine().split(" "); + int parentValue = Integer.parseInt(tokens[0 ]); + Node parentNode = Nodes.get(parentValue); + if(parentNode == null){ + parentNode = new Node(parentValue); + Nodes.put(parentValue, parentNode); + } + + int child1Value = Integer.parseInt(tokens[1]); + if(child1Value != -1){ + Node child1Node = Nodes.get(child1Value); + if(child1Node == null){ + child1Node = new Node(child1Value); + Nodes.put(child1Value, child1Node); + } + parentNode.c1 = child1Node; + } + int child2Value = Integer.parseInt(tokens[2 ]); + if(child2Value != -1){ + Node child2Node = Nodes.get(child2Value); + if(child2Node == null){ + child2Node = new Node(child2Value); + Nodes.put(child2Value, child2Node); + } + parentNode.c2 = child2Node; + } + } + findLastNode(Nodes.get(1)); + answer--; + dfs(Nodes.get(1)); + br.close(); + } + + private static void dfs(Node cur) { + answer++; + if(cur.c1 != null){ + dfs(cur.c1); + answer++; + } + if(q.getLast() == cur.value){ + System.out.println(answer++); + System.exit(0); + } + if(cur.c2 != null){ + dfs(cur.c2); + answer++; + } + } + + private static void findLastNode(Node cur) { + if(cur.c1 != null){ + findLastNode(cur.c1); + } + q.offerLast(cur.value); + if(cur.c2 != null){ + findLastNode(cur.c2); + } + } +} +``` From 827ee2428fd4fae45bcc4c2904acfde8bc8e7d70 Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Fri, 23 Jan 2026 22:39:16 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Rename=2023=20BOJ=20=ED=8A=B8=EB=A6=AC=20?= =?UTF-8?q?=EC=88=9C=ED=9A=8C=20to=2023=20BOJ=20=ED=8A=B8=EB=A6=AC=20?= =?UTF-8?q?=EC=88=9C=ED=9A=8C.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../23 BOJ \355\212\270\353\246\254 \354\210\234\355\232\214.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "LiiNi-coder/202601/23 BOJ \355\212\270\353\246\254 \354\210\234\355\232\214" => "LiiNi-coder/202601/23 BOJ \355\212\270\353\246\254 \354\210\234\355\232\214.md" (100%) diff --git "a/LiiNi-coder/202601/23 BOJ \355\212\270\353\246\254 \354\210\234\355\232\214" "b/LiiNi-coder/202601/23 BOJ \355\212\270\353\246\254 \354\210\234\355\232\214.md" similarity index 100% rename from "LiiNi-coder/202601/23 BOJ \355\212\270\353\246\254 \354\210\234\355\232\214" rename to "LiiNi-coder/202601/23 BOJ \355\212\270\353\246\254 \354\210\234\355\232\214.md"