
Baekjoon/DFS와 BFS
[백준] 2644 촌수계산 (실버2) / DFS, BFS (feat. 파이썬튜터)
문제요약 나의 코드 및 설명 01 - DFS def dfs(s, count, temp_list): #방문한 노드를 temp_list에 담는다 global ans if end in temp_list: ans = count return #리턴필수! 그래야 더 이상 다음 노드 안 담음! for i in graph[s]: if i not in temp_list: #temp_list에 i가 안 담겨 있다면 dfs(i, count+1, temp_list+[i]) n = int(input()) start, end = map(int, input().split()) m = int(input()) graph = [[] for _ in range(n+1)] for _ in range(m): x, y = map(int, in..