알고리즘/백준 다시풀기

    [다시풀기] (백준 7569) 토마토

    알고리즘 BFS [문제 본문] 더보기 HTML 삽입 미리보기할 수 없는 소스 [푼 코드] #include #include #include #define MAXNUM 101 using namespace std; struct Pos { int x; int y; int z; }; int N,M,K; int arr[MAXNUM][MAXNUM][MAXNUM]; bool visit[MAXNUM][MAXNUM][MAXNUM]; int Day[MAXNUM][MAXNUM][MAXNUM] = {0}; int dx[6] = { -1,1,0,0,0,0}; int dy[6] = { 0,0,-1,1,0,0}; int dz[6] = { 0,0,0,0,-1,1}; queue q; bool IsRange(Pos p) { return ..

    [다시풀기] (백준 7576) 토마토

    알고리즘 BFS [문제 본문] 더보기 HTML 삽입 미리보기할 수 없는 소스 [푼 코드] #include #include #include #define MAXNUM 1001 using namespace std; struct Pos { int x; int y; }; int N,M; int arr[MAXNUM][MAXNUM]; bool visit[MAXNUM][MAXNUM]; int Day[MAXNUM][MAXNUM] = {0}; int dx[4] = { -1,1,0,0}; int dy[4] = { 0,0,-1,1}; queue q; bool IsRange(Pos p) { return (p.x >= 0 && p.x = 0 && p.y < M); } void Solved() { while ..

    [다시풀기] (백준 2667) 단지번호붙이기

    알고리즘 BFS [문제 본문] 더보기 HTML 삽입 미리보기할 수 없는 소스 [푼 코드] #include #include #include #include using namespace std; struct Pos { int x; int y; }; int N; int arr[26][26]; int visit[26][26]; int dx[4] = { -1,1,0,0}; int dy[4] = { 0,0,-1,1}; vector vil; bool IsRange(Pos p) { return (p.x >= 0 && p.x = 0 && p.y < N); } void Solved(int x,int y) { visit[y][x] = true; if (arr[y][x] == 0) return; queue..

    [다시풀기] (백준 1012) 유기농 배추

    알고리즘 BFS [문제 본문] 더보기 HTML 삽입 미리보기할 수 없는 소스 [푼 코드] #include #include #include using namespace std; int T, M, N, K; int arr[51][51]; bool visit[51][51]; int dx[4] = { 1,-1,0,0 }; int dy[4] = { 0,0 ,1,-1}; int cnt = 0; bool IsRange(int x, int y) { return (x >= 0 && x = 0 && y < N); } void Solved(int x, int y) { visit[y][x] = true; if (arr[y][x] == 1) { cnt++; queue q; q.push({ x, y }); whi..

    [다시풀기] (백준 11724) 연결 요소의 개수

    알고리즘 BFS [문제 본문] 더보기 HTML 삽입 미리보기할 수 없는 소스 [푼 코드] #include #include #include using namespace std; int N, M; vector v[1001]; bool visit[1001]; queue q; void ResetVisit() { for (int i = 1; i > N >> M; int a, b; for (int i = 0; i > a >> b; v[a].push_back(b); v[b].push_back(a); } ResetVisit(); int cnt = 0; for (int i = 1; i

    [다시풀기] (백준 2606) 바이러스

    알고리즘 DFS [문제 본문] 더보기 HTML 삽입 미리보기할 수 없는 소스 [푼 코드] #include #include #include using namespace std; int N, M; vector v[1001]; bool visit[1001] = {false}; int cnt = -1 ; void ResetVisit() { for (int i = 1; i > N >> M; int a, b; for (int i = 0; i > a >> b; v[a].push_back(b); v[b].push_back(a); } ResetVisit(); DFS(1); cout