Notice
Recent Posts
Recent Comments
Link
목록1068 (1)
나의 개발일지
문제 : https://www.acmicpc.net/problem/1068 DFS 부모 노드를 지우면 자식 노드로 갈 길이 없어지기 때문에 제거해야 할 노드만 지우면 자식 노드들을 다 지울 필요 없다. import sys from collections import defaultdict input = sys.stdin.readline tree = defaultdict(list) n = int(input()) nodes = list(map(int, input().split())) remove_node = int(input()) for i in range(n): if i != remove_node: # 제거해야 할 노드 제외하고 추가 tree[nodes[i]].append(i) if remove_node in..
백준
2023. 9. 15. 18:34