(C++) - 백준(BOJ) 2178번 : 미로 찾기 답
https://www.acmicpc.net/problem/2178 간단한 BFS문제였습니다. 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748#include #include #include using namespace std;int h, w, N, M,cnt, d[101][101], a[101][101],c[101][101], dh[] = { 0,0,-1,1 }, dw[] = { -1,1,0,0};void BFS(int h, int w){ queue q; q.push(make_pair(h, w)); //체크 d[h][w] = ++cnt; c[h][w] = 1; while (!q.empty()) { ..
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 4963번:섬의 개수(DFS) 답
1234567891011121314151617181920212223242526272829303132333435#include #include using namespace std;int h,w,a[51][51], d[51][51], cnt, dh[] = { 0,0,-1,1,1,1,-1,-1 }, dw[] = { -1,1,0,0,-1,1,-1,1 };void DFS(int H, int W, int cnt){ d[H][W] = cnt; for (int i = 0; i
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 4963번:섬의 개수(BFS) 답
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647#include #include #include using namespace std;int d[51][51],a[51][51], cnt, dx[] = {0,0,-1,1,1,1,-1,-1}, dy[] = {-1,1,0,0,1,-1,1,-1 },w,h;void BFS(int x, int y, int cnt){ queue q; q.push(make_pair(x, y)); d[x][y] = cnt; while (!q.empty()) { x = q.front().first; y = q.front().second; q.pop(); for (int i = 0; i
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 2667번:단지번호붙이기(DFS) 답
DFS로 푼 정답 입니다 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263#include #include using namespace std;int c[1000], a[26][26], d[26][26], N, cnt, dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };int compare(const void *a, const void *b){ return *(int*)a - *(int*)b;}void DFS(int i,int j, int cnt){ d[i][j] = 1; d[i][j] = cnt; { for(int k ..
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 2667번:단지번호붙이기(BFS) 답
BFS로 푼 답 입니다 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273#include #include #include using namespace std; int c[1000], a[26][26], d[26][26], N, cnt, dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };int compare(const void *a, const void *b){ return *(int*)a - *(int*)b;}void BFS(int i,int j, int cnt){ queue q; q...