백준[Python] 1260.DFS와 BFS - 파이썬


백준[Python] 1260.DFS와 BFS - 파이썬

문제 코드 from collections import deque import sys input = sys.stdin.readline N, M, V = map(int, input().split()) matrix = [[0]*(N+1) for i in range(N+1)] visited = [False] * (N+1) visited1 = [False] * (N+1) for i in range(M): a, b = map(int, input().split()) matrix[a][b] = matrix[b][a] = 1 def dfs(V): visited[V] = True print(V, end=" ") # 수행동작 for i in range(N+1): if visited[i] == False and mat..


원문링크 : 백준[Python] 1260.DFS와 BFS - 파이썬