반응형
문제
https://www.acmicpc.net/problem/6080
6080번: Bad Grass
Bessie was munching on tender shoots of grass and, as cows do, contemplating the state of the universe. She noticed that she only enjoys the grass on the wide expanses of pasture whose elevation is at the base level of the farm. Grass from elevations just
www.acmicpc.net
풀이
Bad Grass의 개수를 찾는 문제입니다.
0 이상의 숫자로 된 섬이 Bad Grass 입니다.
0보다 큰 숫자에 대해서 상하좌우 + 대각선까지 총 8방향에 대해 탐색해주어야 합니다.
0보다 크다면 bfs or dfs로 순회하여 연결 요소의 개수를 구하는 문제입니다.
소스코드
후기
간단한 그래프 문제였습니다.
반응형
'PS > 백준' 카테고리의 다른 글
[BOJ] 백준 28278 스택 2 (Swift) (0) | 2023.08.15 |
---|---|
[BOJ] 백준 1205 등수 구하기 (Swift) (0) | 2023.06.14 |
[BOJ] 백준 1543 문서 검색 (Swift) (0) | 2023.06.02 |
[BOJ] 백준 3085 사탕 게임 (Swift) (0) | 2023.06.02 |
[BOJ] 백준 18352 특정 거리의 도시 찾기 (Swift) (0) | 2023.06.02 |