Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

[2023-08-16] wooyeol #112 #127

Merged
merged 2 commits into from
Aug 22, 2023
Merged

[2023-08-16] wooyeol #112 #127

merged 2 commits into from
Aug 22, 2023

Conversation

Woo-Yeol
Copy link
Member

@Woo-Yeol Woo-Yeol commented Aug 16, 2023

PR Summary

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

풀이시간
10:33 ~ 14:12 (풀이 실패) + 4시간 (풀이 성공)

접근법
무슨 알고리즘으로 풀이 할 수 있을까? BFS

시간 초과와 메모리 초과로 실패했습니다. -> 리뷰를 보며 다시 풀이를 진행하여 풀이해낼 수 있었습니다.

  • 빙산 테이블을 만들면서 빙산의 위치를 덱에 기억시켜놓고 첫 요소를 기점으로 BFS로 진행합니다.
    • BFS 연산을 거치며 해당 빙산 주변 바다의 갯수를 통해 빙산의 높이를 조절합니다.
  • 하나의 빙산 덩어리는 첫 요소를 기점으로 BFS를 진행하였을 때 모든 요소를 탐색 할 수 있습니다.
  • 혹시라도 빙산의 위치를 저장시킨 덱의 요소를 다 검사하였을 때 한 번 더 BFS 탐색을 한다면 두 개의 빙산 덩어리가 발생하였다는 것 이므로 현재 연도를 반환
  • 만약 BFS 연산이 일어나지 않았다면 0개의 덩어리라는 것이므로 0을 반환

@Woo-Yeol Woo-Yeol self-assigned this Aug 16, 2023
@Woo-Yeol Woo-Yeol changed the title Create 빙산 wooyeol.py [2023-08-16] wooyeol #112 Aug 16, 2023
@Woo-Yeol Woo-Yeol added the BOJ label Aug 16, 2023
@Woo-Yeol Woo-Yeol linked an issue Aug 16, 2023 that may be closed by this pull request
year, x, y = queue.popleft()

if year > pre_year:
iceberg = copy.deepcopy(record_iceberg)
Copy link
Member Author

Choose a reason for hiding this comment

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

@Woo-Yeol
Copy link
Member Author

@ksumini @zsmalla @limstonestone 새로 풀이를 진행하였으며 이전 코드도 wooyeol2.py 파일에 작성해놓았습니다. 시간 있으실 때 편하게 리뷰 해주시면 감사하겠습니다! ㅎㅎ

Copy link
Contributor

@zsmalla zsmalla left a comment

Choose a reason for hiding this comment

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

빙산의 위치를 덱에 관리해서 보다 효율적으로 코드를 구성하셨습니다. 이 점이 좋았던 것 같습니다. 우열님께서 포기하지 않고 깔끔하게 코드를 작성할 수 있어서 너무 보기 좋은 것 같습니다. 고생하셨습니다.


R, C = map(int, input().split())

iceberg_queue: deque = deque()
Copy link
Contributor

Choose a reason for hiding this comment

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

iceberg_queue라는 작업 큐를 두신 게 굉장히 좋은 것 같아요! 저는 set 자료형으로 매번 copy를 했었는데 copy해서 메모리가 계속 쌓이는 것보다 이 방식이 더 좋아보입니다 👍👍 고생하셨어요 우열님~!!!

@Woo-Yeol Woo-Yeol merged commit 5803005 into main Aug 22, 2023
@Woo-Yeol Woo-Yeol deleted the wooyeol-#112 branch August 22, 2023 12:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BOJ] 빙산
3 participants