From d50679b5cf6cc0ead647fe25b941551bad3b9176 Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Sun, 24 Aug 2025 21:58:15 +0900 Subject: [PATCH] 20250824 baekjoon --- code_study/Baekjoon/ts/11725.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 code_study/Baekjoon/ts/11725.ts diff --git a/code_study/Baekjoon/ts/11725.ts b/code_study/Baekjoon/ts/11725.ts new file mode 100644 index 0000000..972c471 --- /dev/null +++ b/code_study/Baekjoon/ts/11725.ts @@ -0,0 +1,27 @@ +export {}; + +const input: string[] = require("fs").readFileSync(0, 'utf8').toString().trim().split('\n'); + +const N: number = Number(input[0]); +let linked: number[][] = Array.from({length: N+1}, () => []); +for(let i=1; i 0); +root[1] = -1; +let queue: number[] = [1]; + +while(queue.length !== 0) { + const current: number = queue.shift()!; + for(let v of linked[current]) { + if(root[v] === 0) { + root[v] = current; + queue.push(v); + } + } +} + +console.log(root.slice(2).join('\n')); \ No newline at end of file