본문 바로가기

반응형

Algorithm_BOJ(백준)/깊이,너비우선탐색(DFS,BFS)

(47)
[백준 1697 c++ VVO] 숨바꼭질 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 1697 c++ VVO] 숨바꼭질 // 문제: n에서 k 까지 걸리는 최소시간을 구해라 // 접근: 최소이동횟수 -> 완탐,그리디,dp,bfs-> 완탐은 시간 3^10만 = 시간초과 // 접근2: bfs -..
[백준 7576 c++ VOO] 토마토 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 7576 c++ VOO] 토마토 // 문제: 이차원 그래프에 주어진 토마토가 모드 익는데 걸리는 최소일 ..
[백준 2178 c++ VOV] 미로 탐색 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 2178 c++ VOV] 미로 탐색 // 문제: 미로가 주어졌을 때, (1, 1)에서 출발하여 (N, M)의 위치로 이동할 때 지나야 하는 최소의 칸 수 // 접근..
[백준 2667 c++ VOOO] 단지번호붙이기 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 2667 c++ VOOO] 단지번호붙이기 // 문제: 각 단지별로 단지의 갯수와 단지마다의 아파트 갯수 구하기 // 접근: 각 단지의 행렬 구역 탐색 -..
[백준 1707 c++ VV] 이분 그래프 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 1707 c++ VV] 이분 그래프 // 문제:각 집합에 속한 정점끼리는 서로 인접하지 않도록 분할된 이분 그래프 인지 검사 // 접근1..
[백준 11724 c++ OO] 연결 요소의 개수 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 11724 c++ OO] 연결 요소의 개수 // 문제: 양방향 그래프의 연결 요소(= 서로 연결되어있지 않은 집단) 의 개수를 구하라 // 접근1: 1차원 그래프-> dfs-> 기본 인접리스트로 구현 -> 모든 노드에 대해서 dfs탐색 시..
[백준 1260 c++ VOOO] DFS와 BFS 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 #include using namespace std; // [백준 1260 c++ VOOO] DFS와 BFS // 문제: 기본 dfs,bfs 방문 노드 출력 // 접근1: 1차원 그..
[백준 16929 c++ O] Two Dots 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 #define _CRT_SECURE_NO_WARNINGS #include #include #include #include // memset 헤더 using namespace std; // [백준 16929 c++ O] Two Dots // 문제: 이차원 그래프에서 길이가 4 이상인 사이클의 존재 유무 출력 // 접근: 이차원 그래프 하나씩 탐색하며 싸이클 ..

반응형