Notice
Recent Posts
Recent Comments
Link
목록연결 요소의 개수 (1)
Be a developer
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/TTuae/btqubgtJkGW/x9ln5W3NZVAaIgw1649Mv0/img.png)
각 정점을 돌면서 bfs를 돌리면 된다. 필요 없는 실행을 줄이기 위해서 bfs들어가기 전 방문했는지 check 배열을 통해 알아본다. 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152#include #include #include #include #include using namespace std; int n, m, ans;bool check[1000000];vector g[1001]; void bfs(int x) { queue q; //처음 넣는 node를 check해야 한다. check[x] = true; q.push(x); while (!q.empty()) { int curre..
알고리즘
2019. 4. 5. 20:14