BFS

알고리즘 문제 풀이/1DP_과제(~180615)

171120_1389_케빈 베이컨의 6단계 법칙

#include #include using namespace std;bool map[102][102];bool visit[101] = {0};int N, M;int sum; int bfs(int start, int end){ queue > q; for(int i=1; i N >> M; for(int i=1; i> a >> b; map[a][b]=1; map[b][a]=1; } int min = 100; int min_index; for(int i=1; i

알고리즘 문제 풀이/1DP_과제(~180615)

171102_11403_경로찾기

#include #include using namespace std; bool G[102][102]; int find(int start, int end, int N) { bool visited[102] = { 0 }; queue q; q.push(start); int next; int now = q.front(); while (!q.empty()) { now = q.front(); q.pop(); for (int i = 1; i > N; input_G(N); for (int i = 1; i

알고리즘 문제 풀이/1DP_과제(~180615)

171102_2178_미로탐색

#include #include using namespace std; struct cord { int x; int y; }; bool map[102][102]; int visited[102][102]; void input_map(int N, int M) { char c; for (int i = 1; i c; if (c == '1') map[i][j] = 1; else map[i][j] = 0; } } int solv_maze(int n, int m, cord s) { //int cnt = 0; queue q; q.push(s); cord next; cord now = q.front(); visited[now.y][now.x] = 1; while (!q.empty()) { now = q.front(); q..

bong sue
'BFS' 태그의 글 목록 (4 Page)