Skip to content

Commit

Permalink
#21 : 2606_바이러스
Browse files Browse the repository at this point in the history
#21 : Week5_예원이티
  • Loading branch information
yewonahn authored May 17, 2023
1 parent de89484 commit dbfc98d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions 이티예원/2606_바이러스.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from collections import deque

computer = int(input())
v = int(input())
graph = [[] for i in range(computer+1)]
visited = [0]*(computer+1)

for i in range(v):
a, b = map(int, input().split())
graph[a] += [b]
graph[b] += [a]


visited[1] = 1
Q = deque([1])

while Q:
c = Q.popleft()
for nx in graph[c]:
if visited[nx]==0:
Q.append(nx)
visited[nx]=1

print(sum(visited)-1)

1 comment on commit dbfc98d

@plum-king
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수업 시간에 말씀드렸던 코드 활용하여 문제 잘 풀어주신 것 같습니다! 문제 푸시느라 고생 많으셨습니다 👍🏻

Please sign in to comment.