일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
Tags
- cyworld
- react native mac
- stencil buffer
- react native typescript
- c++ 정보은닉
- 리액트 네이티브 설치 오류
- node.js
- 스탠실 버퍼 시작
- html
- react native accessible
- unity stencil buffer
- react native typescript navigate
- react-native
- C++
- GitHub
- node
- react native typescript navigation
- 스탠실 버퍼 사용
- CSS
- react native ios 기기 연결
- javascript
- react native 타입스크립트
- 싸이월드
- 리액트 네이티브 맥
- Expo
- 벡터와 리스트의 차이
- react
- react native
- 스탠실 버퍼 튜토리얼
- c++ using
Archives
- Today
- Total
혀니의 이거저거 뿌시기
[C++]프로그래머스 네트워크 본문
728x90
#include <string>
#include <vector>
using namespace std;
bool isVisited[200] = {false, };
void DFS(int cur, int n, vector<vector<int>> computers)
{
isVisited[cur] = true;
for(int i = 0; i < n; i++)
{
if(!isVisited[i] && computers[cur][i] == 1)
DFS(i, n, computers);
}
}
int solution(int n, vector<vector<int>> computers) {
int answer = 0;
for(int i = 0; i < n; i++)
{
if(!isVisited[i]){
DFS(i, n, computers);
answer++;
}
}
return answer;
}
가장
728x90
'알고리즘 공부(C++)' 카테고리의 다른 글
[C++]프로그래머스 배달 (다익스트라 알고리즘 이해) (0) | 2023.06.20 |
---|---|
BFS 이해 (0) | 2023.06.11 |
[C++]프로그래머스 소수 찾기 (next_permutation) (0) | 2023.06.06 |
[C++]프로그래머스 숫자 변환하기(BFS) (0) | 2023.06.04 |
프로그래머스 C++ 타겟 넘버 (DFS) (0) | 2023.05.30 |