단지번호 붙이기
-
[백준][2667번] 단지번호 붙이기알고리즘/백준 2021. 8. 9. 20:29
문제 링크 풀이 아직 방문하지 않은 집을 방문해 인덱스를 큐에 넣고, 인접 노드를 검사해 방문한 적 없는 집이라면 해당 인덱스를 큐에 넣는 걸 반복합니다. 코드 #include #include using namespace std; int main() { int N; scanf("%d", &N); char map[25][25] = {}; bool flag[25][25] = {}; int row_dir[] = {0, 1, 0, -1}; int col_dir[] = {1, 0, -1, 0}; for (int i = 0; i < N; ++i) scanf("%s", map[i]); priority_queue pq; int count = 0; for (int i = 0; i < N; ++i) { int answer..