#include <string>
#include <vector>
#include <cstring>
using namespace std;
const int MAX = 201;
int visited[MAX];
void dfs(int i,int n, vector<vector<int>> c) {
if (visited[i] == 1)
return;
else
visited[i] = 1;
for (int k = 0; k < n; k++) {
if (k == i)
continue;
if (c[i][k] == 1)
dfs(k, n, c);
}
}
int solution(int n, vector<vector<int>> computers) {
int answer = 0;
memset(visited, -1, sizeof(visited));
for (int i = 0; i < n; i++) {
if (visited[i] == -1) {
dfs(i,n,computers);
answer++;
}
}
return answer;
}
프로그래머스