forked from satnaing/astro-paper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Affected files: .obsidian/workspace.json src/assets/template/oakgorithms-report-template.md src/content/blog/boj-11725-트리의-부모-찾기.md src/content/blog/computer-science-qna.md
- Loading branch information
Showing
4 changed files
with
90 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,25 @@ | |
"state": { | ||
"type": "markdown", | ||
"state": { | ||
"file": "src/content/blog/computer-science-qna.md", | ||
"file": "src/content/blog/boj-11725-트리의-부모-찾기.md", | ||
"mode": "source", | ||
"source": false | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "2751c6eff19f0222", | ||
"type": "tabs", | ||
"children": [ | ||
{ | ||
"id": "b432993a3c090840", | ||
"type": "leaf", | ||
"state": { | ||
"type": "markdown", | ||
"state": { | ||
"file": "src/content/blog/boj-1026-보물.md", | ||
"mode": "source", | ||
"source": false | ||
} | ||
|
@@ -85,7 +103,7 @@ | |
"state": { | ||
"type": "backlink", | ||
"state": { | ||
"file": "src/content/blog/computer-science-qna.md", | ||
"file": "src/content/blog/boj-11725-트리의-부모-찾기.md", | ||
"collapseAll": false, | ||
"extraContext": false, | ||
"sortOrder": "alphabetical", | ||
|
@@ -102,7 +120,7 @@ | |
"state": { | ||
"type": "outgoing-link", | ||
"state": { | ||
"file": "src/content/blog/computer-science-qna.md", | ||
"file": "src/content/blog/boj-11725-트리의-부모-찾기.md", | ||
"linksCollapsed": false, | ||
"unlinkedCollapsed": true | ||
} | ||
|
@@ -125,7 +143,7 @@ | |
"state": { | ||
"type": "outline", | ||
"state": { | ||
"file": "src/content/blog/computer-science-qna.md" | ||
"file": "src/content/blog/boj-11725-트리의-부모-찾기.md" | ||
} | ||
} | ||
} | ||
|
@@ -150,6 +168,9 @@ | |
}, | ||
"active": "3102d8e704fadc57", | ||
"lastOpenFiles": [ | ||
"src/content/blog/computer-science-qna.md", | ||
"src/content/blog/boj-1026-보물.md", | ||
"src/content/blog/boj-11725-트리의-부모-찾기.md", | ||
"src/content/blog/boj-15663-N과-M-(9).md", | ||
"dist/assets/[email protected]", | ||
"dist/assets/forrest-gump-quote.webp.jpg", | ||
|
@@ -174,7 +195,6 @@ | |
"src/content/blog/boj-15664-N과-M-(10).md", | ||
"src/content/blog/boj-1935-후위-표기식2.md", | ||
"src/content/blog/boj-10819-차이를-최대로.md", | ||
"src/content/blog/boj-1026-보물.md", | ||
"src/content/blog/programmers-보호소에서-중성화한-동물.md", | ||
"src/content/blog/programmers-즐겨찾기가-가장-많은 식당-정보-출력하기.md", | ||
"src/content/blog/boj-5014-스타트링크.md", | ||
|
@@ -193,7 +213,6 @@ | |
"src/content/blog/update-markdown-AST-node-url-value.md", | ||
"src/content/blog/uninstall-wsl-completely-on-windows.md", | ||
"src/content/blog/wooteco-2nd-thoughts.md", | ||
"src/content/blog/wooteco-1st-thoughts.md", | ||
"src/content/blog/create-ssh-key-for-github.md" | ||
"src/content/blog/wooteco-1st-thoughts.md" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
author: Gyunseo Lee | ||
title: "BOj 백준 11725: 트리의 부모 찾기" | ||
pubDatetime: 2024-04-28T23:40:00+09:00 | ||
modDatetime: 2024-04-28T23:40:00+09:00 | ||
featured: false | ||
draft: false | ||
tags: | ||
- PS | ||
- Algorithms | ||
- BOJ | ||
- BFS | ||
- 실랜디 | ||
description: "\b백준 11725: 트리의 부모 찾기 풀이 과정" | ||
ogImage: "" | ||
--- | ||
|
||
## Table of contents | ||
|
||
## 들어가며 | ||
|
||
이 문제는 BFS를 돌리면서 각 노드를 방문하고, 각 노드에 대해 직전에 방문했던 노드를 기록해주는 리스트를 만들어서 기록해주어서 푸는 문제이다. | ||
|
||
## 풀이 과정 | ||
|
||
![](https://res.cloudinary.com/gyunseo-blog/image/upload/f_auto/v1714315356/image_ecudal.png) | ||
|
||
## AC 받은 Python 코드 | ||
|
||
```python | ||
import sys | ||
from collections import deque | ||
|
||
input = sys.stdin.readline | ||
|
||
|
||
if __name__ == "__main__": | ||
N = int(input().rstrip()) | ||
graph = [[] for _ in range(N + 1)] | ||
isVisited = [False for _ in range(N + 1)] | ||
pre = [0 for _ in range(N + 1)] | ||
for _ in range(N - 1): | ||
u, v = map(int, input().rstrip().split()) | ||
graph[u].append(v) | ||
graph[v].append(u) | ||
q = deque() | ||
isVisited[1] = True | ||
q.append(1) | ||
while q: | ||
cur = q.popleft() | ||
for nv in graph[cur]: | ||
if isVisited[nv]: | ||
continue | ||
isVisited[nv] = True | ||
pre[nv] = cur | ||
q.append(nv) | ||
for i in range(2, N + 1): | ||
print(pre[i]) | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters