Skip to content

Commit dbfc98d

Browse files
authored
#21 : 2606_바이러스
#21 : Week5_예원이티
1 parent de89484 commit dbfc98d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

이티예원/2606_바이러스.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from collections import deque
2+
3+
computer = int(input())
4+
v = int(input())
5+
graph = [[] for i in range(computer+1)]
6+
visited = [0]*(computer+1)
7+
8+
for i in range(v):
9+
a, b = map(int, input().split())
10+
graph[a] += [b]
11+
graph[b] += [a]
12+
13+
14+
visited[1] = 1
15+
Q = deque([1])
16+
17+
while Q:
18+
c = Q.popleft()
19+
for nx in graph[c]:
20+
if visited[nx]==0:
21+
Q.append(nx)
22+
visited[nx]=1
23+
24+
print(sum(visited)-1)

0 commit comments

Comments
 (0)