117241 백준 11724 연결 요소의 개수 import sys sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline n, m = map(int, input().split()) connect = [[False] * n for _ in range(n)] for _ in range(m) : x, y = map(int, input().split()) connect[x-1][y-1] = True connect[y-1][x-1] = True answer = 0 check = [False] * n def dfs(i): for j in range(n): if not check[j] and connect[i][j] : check[j] = True dfs(j) for i in range(n): if not chec.. 2022. 6. 13. 이전 1 다음