킹솔이
[백준/Python] 2606 바이러스 본문
computerNo = int(input())
pairNo = int(input())
graph = []
for i in range(101):
graph.append([])
answer = [0] * 101
answer[1] = 1
for i in range(pairNo):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
def dfs(x):
for i in graph[x]:
if answer[i]==0:
answer[i]=1
dfs(i)
dfs(1)
print(answer.count(1)-1)
'Algorithm' 카테고리의 다른 글
[백준/Python] 14867 물통 (0) | 2021.01.13 |
---|---|
[백준/Python] 1202 보석 도둑 (0) | 2021.01.08 |
[백준/Python] 2891 카약과 강풍 (1) | 2021.01.06 |
[프로그래머스/C++] 서머코딩/윈터코딩(~2018) 쿠키 구입 (0) | 2020.03.09 |
[프로그래머스/C++] 서머코딩/윈터코딩(~2018) 방문길이 (0) | 2020.02.19 |