Skip to content

Conversation

@ShineCorine
Copy link
Collaborator

문제 및 풀이과정

석유 시추
소요 시간 : 60분

  • 전에 아파트 단지 구성했던 문제를 풀이했던 방식과 비슷하게 풀었습니다.
  • 처음에는 너비 우선 탐색 방식으로 각 석유 덩어리를 탐색하여 각 석유 덩어리의 크기와 함께 , 덩어리의 좌우를 리턴하도록 하였습니다.
  • 해당하는 열 만큼 각 석유의 양을 더하고 최종적으로 그 중 최대값을 리턴하는 식으로 풀었습니다.
  • 시간은 다소 오래걸렸는데, 검색 안하고 그동안 풀었던 것을 활용하여 IDE의 도움 없이 풀었다는 점에서 고무적인 것 같습니다.
  • 덕분에 코드는 다소 엉망이라 보시기 힘들지도 모르겠습니다.

궁금한 점

@ShineCorine ShineCorine added the PRG 프로그래머스 label Mar 20, 2024
@ShineCorine ShineCorine requested a review from kkkapuq March 20, 2024 11:43
@ShineCorine ShineCorine self-assigned this Mar 20, 2024
@ShineCorine
Copy link
Collaborator Author

혹시나 해서 실행시간도 같이 올리겠습니다

테스트 1 〉 통과 (0.46ms, 78.1MB)
테스트 2 〉 통과 (0.77ms, 79.5MB)
테스트 3 〉 통과 (0.35ms, 76.9MB)
테스트 4 〉 통과 (0.48ms, 75.6MB)
테스트 5 〉 통과 (0.34ms, 75.5MB)
테스트 6 〉 통과 (1.33ms, 73.2MB)
테스트 7 〉 통과 (1.72ms, 77.6MB)
테스트 8 〉 통과 (1.02ms, 72.4MB)
테스트 9 〉 통과 (4.07ms, 76.8MB)

테스트 1 〉 통과 (25.04ms, 63.2MB)
테스트 2 〉 통과 (48.98ms, 71.8MB)
테스트 3 〉 통과 (102.39ms, 71.2MB)
테스트 4 〉 통과 (26.80ms, 61.9MB)
테스트 5 〉 통과 (68.71ms, 66.8MB)
테스트 6 〉 통과 (26.63ms, 62.3MB)

@ShineCorine ShineCorine changed the title Week17/tue2 [Solved] PRG_레벨2_석유 시추 Mar 20, 2024
Comment on lines +22 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이부분 좀 궁금한게..
제가 안됐던 이유는 석유가 있는 모든 땅에서 dfs를 돌렸기때문에 시초가 났단말이죠?
근데 이것도 결국엔 석유가 있는 모든 땅에서 bfs를 돌려서 똑같은거아닌가요..? 진짜 너무답답함..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기서 visited가 초기화가 되지 않아요. 따라서 앞에서 true로 표시된 땅은 다시 탐색을 하지 않게 했어요. 그래서 석유 덩어리를 계산하는데 드는 시간이 최대 mxn이 되는데요, 만약에 초기화를 했다면 저기에다가 매 컬럼 에서 매 로우를 탐색할 때마다 포함된 석유를 계산하게 돼요. 만약에
000000
110000
110000
000000
이런식으로 매장이 되어 있다면 저 4개짜리 덩어리를 총 4회 탐색하게 되는 것 같아요 여기서는 dfs나 bfs는 크게 상관이 없는 것 같아요. 만약에 제가 재귀함수를 사용했다면 isVisited를 메인 밖에서 static으로 선언해서 같은 방법으로 수행했을 것 같아요.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아..그러네요 어떤건지 좀 느낌이 올것같습니다 답변 감사합니다!! 오늘다시해본다 ㅠ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PRG 프로그래머스

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants