Skip to content

Conversation

@JHLEE325
Copy link
Contributor

🧷 문제 링크

https://www.acmicpc.net/problem/2573

🧭 풀이 시간

40분

👀 체감 난이도

✏️ 문제 설명

격자맵에 빙산의 높이가 주어지고 1년마다 각 칸의 얼음을 둘러싼 바다만큼 녹을 때(상하좌우)
빙산이 2개 이상으로 분리되는 년수를 구하는 문제입니다

🔍 풀이 방법

bfs를 이용하여 풀이했습니다.
각 시행마다 배열을 순회하며 bfs를 시작하고 bfs를 새로 시작하는 경우에 빙산이 분리되었다고 판단하는 식으로 풀이했습니다.

static int countice() {
        visited = new boolean[n][m];
        int count = 0;

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (map[i][j] > 0 && !visited[i][j]) {
                    bfs(i, j);
                    count++;
                }
            }
        }
        return count;
    }

⏳ 회고

얼음을 녹이면서 bfs를 하면 안되는 등 생각할 부분이 있는 구현문제였던 것 같습니다.

@ShinHeeEul ShinHeeEul merged commit a1b8f6a into main Jul 19, 2025
1 check passed
@JHLEE325 JHLEE325 added the success 👍 해설을 보지 않고 풀었을 때 label Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

success 👍 해설을 보지 않고 풀었을 때

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants