From a76e9367a6355c4a5c9c3c7d92118fcc40bc3e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B3=A0=ED=98=81=EB=B9=88?= Date: Wed, 3 Sep 2025 14:04:38 +0900 Subject: [PATCH] =?UTF-8?q?2025.09.03=20-=20PCCP=20=EA=B8=B0=EC=B6=9C=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20/=20=EC=84=9D=EC=9C=A0=20=EC=8B=9C?= =?UTF-8?q?=EC=B6=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\234\240 \354\213\234\354\266\224.cpp" | 75 +++++++++++++++++++ hyeokbini/README.md | 1 + 2 files changed, 76 insertions(+) create mode 100644 "hyeokbini/PCCP \352\270\260\354\266\234\353\254\270\354\240\234#2 - \354\204\235\354\234\240 \354\213\234\354\266\224/\354\204\235\354\234\240 \354\213\234\354\266\224.cpp" diff --git "a/hyeokbini/PCCP \352\270\260\354\266\234\353\254\270\354\240\234#2 - \354\204\235\354\234\240 \354\213\234\354\266\224/\354\204\235\354\234\240 \354\213\234\354\266\224.cpp" "b/hyeokbini/PCCP \352\270\260\354\266\234\353\254\270\354\240\234#2 - \354\204\235\354\234\240 \354\213\234\354\266\224/\354\204\235\354\234\240 \354\213\234\354\266\224.cpp" new file mode 100644 index 0000000..2e72e0a --- /dev/null +++ "b/hyeokbini/PCCP \352\270\260\354\266\234\353\254\270\354\240\234#2 - \354\204\235\354\234\240 \354\213\234\354\266\224/\354\204\235\354\234\240 \354\213\234\354\266\224.cpp" @@ -0,0 +1,75 @@ +#include +using namespace std; + +int row, col; +int dx[4] = {0, 1, -1, 0}; +int dy[4] = {1, 0, 0, -1}; +vector v; +vector> visited; + +void func(vector>& land, int x, int y) +{ + queue> Q; + + Q.push({x, y}); + visited[x][y] = true; + + int cnt = 0; + int ymin = y, ymax = y; + + while(!Q.empty()) + { + pair cur = Q.front(); + Q.pop(); + cnt++; + + // YMIN, YMAX 계산 + if(cur.second < ymin) ymin = cur.second; + if(cur.second > ymax) ymax = cur.second; + + for(int i = 0; i < 4; i++) + { + int nx = cur.first + dx[i]; + int ny = cur.second + dy[i]; + + if(nx < 0 || ny < 0 || nx >= col || ny >= row) continue; + if(land[nx][ny] == 0 || visited[nx][ny]) continue; + + visited[nx][ny] = true; + Q.push({nx, ny}); + } + } + + // YMIN과 YMAX 내에서 크기 누적 + for(int i = ymin; i <= ymax; i++) + { + v[i] += cnt; + } +} + +int solution(vector> land) { + int ans = 0; + row = land[0].size(); + col = land.size(); + visited.resize(col,vector(row,false)); + v.resize(row,false); + + for(int i = 0; i < col; i++) + { + for(int j = 0; j < row; j++) + { + if(land[i][j] == 1 && visited[i][j] == false) + { + func(land, i, j); + } + } + } + + // 최대값 계산 + for(int i = 0; i < row; i++) + { + ans = max(v[i], ans); + } + + return ans; +} diff --git a/hyeokbini/README.md b/hyeokbini/README.md index 182728a..9100113 100644 --- a/hyeokbini/README.md +++ b/hyeokbini/README.md @@ -23,3 +23,4 @@ | 19차시 | 2025.08.10 | 브루트포스 | [리모컨](https://www.acmicpc.net/problem/1107)|[#19](https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/68)| | 20차시 | 2025.08.14 | 완전탐색,DFS | [모음사전](https://school.programmers.co.kr/learn/courses/30/lessons/84512)|[#20](https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/72)| | 21차시 | 2025.08.19 | 브루트포스 | [제곱수 찾기](https://www.acmicpc.net/problem/1025)|[#21](https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/76)| + | 24차시 | 2025.09.03 | BFS, 구현 | [석유 시추](https://school.programmers.co.kr/learn/courses/30/lessons/250136)|[#24](https://github.com/AlgoLeadMe/AlgoLeadMe-15/pull/83)| \ No newline at end of file