1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import sys def dfs(graph, v): global total visited[v] = True total += 1 for i in graph[v]: if not visited[i]: dfs(graph, i) n = int(sys.stdin.readline().strip()) m = int(sys.stdin.readline().strip()) arr = [[] for _ in range(n + 1)] total = 0 for _ in range(m): a, b = map(int, sys.stdin.readline().rstrip().split()) arr[a].append(b) arr[b].append(a) visited = [False] * (n + 1) dfs(arr, 1) print(total – 1) | cs |