
import sys
input = sys.stdin.readline
N = int(input())
conn_num = int(input())
networks = [[0] * (N + 1) for _ in range(N+1)]
for _ in range(conn_num):
a, b = map(int, input().split())
networks[a][b] = 1; networks[b][a] = 1
def dfs(current_node, networks, foot_print):
foot_print += [current_node]
for search_node in range(len(networks[current_node])):
if networks[current_node][search_node] and search_node not in foot_print:
foot_print = dfs(search_node, networks, foot_print)
return foot_print
result = dfs(1, networks, [])
print(len(result) - 1)
'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글
백준 7569번(python) (0) | 2020.08.02 |
---|---|
백준 7576번(python) (0) | 2020.08.02 |
백준 2805번(python) (0) | 2020.07.27 |
백준 1654번(python) (0) | 2020.07.27 |
백준 10816번(python) (0) | 2020.07.19 |