We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent de89484 commit dbfc98dCopy full SHA for dbfc98d
1 file changed
이티예원/2606_바이러스.py
@@ -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